Topics

Cascading issues with missing functionality


Ali Kayn
 

I am having issues with renaming directories (folders) and /or moving files. I want to change the standardised names on my server. Thousands and thousands of directories. My first problem is that there is no command for renaming a directory. My workaround was to create a new directory using the new standards, moving the files from the original directory, and then deleting the original directory. BUT...

Not all the directories are empty, some of them have subdirectories. The movefile command doesn't move the subdirectories or their contents, and the clip ERRORS.

I've tried using ^!IfError to run a subroutine to collect a list of these subdirectories and then continue. Should I be using DOS commands through the shell, or a PERL script instead?
--
ALi


John Shotsky
 

I would do it on the DOS command line.
Here's a tutorial for that. https://www.computerhope.com/issues/ch000846.htm
You can use clips to get a list of folder names, then execute the rename in a loop.
Here's the line that should do it:
^$GetOutput(cmd.exe /c ren "originalfoldername" "newfoldername")$
Don't forget to use double quotes if any spaces are in folder names. I'd store the path in a variable then append that to the foldernames.
You can rename with wildcards too, but obviously, you would have to be pretty careful. I'd back up the whole server and work on a few samples until you have it worked out. I would be concerned that something in the server pages might have a hard-coded folder name, which would break the server.
Subdirectories would not be affected. You'd have to change folders to get at the subdirectory names, if you want those changed too.
But anyway, the renaming part can be done in NoteTab using the above command.
Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of Ali Kayn
Sent: Saturday, June 27, 2020 6:22 AM
To: Clips@Notetab.groups.io
Subject: [NTB-Clps] Cascading issues with missing functionality

I am having issues with renaming directories (folders) and /or moving files. I want to change the standardised names on my server. Thousands and thousands of directories. My first problem is that there is no command for renaming a directory. My workaround was to create a new directory using the new standards, moving the files from the original directory, and then deleting the original directory. BUT...

Not all the directories are empty, some of them have subdirectories. The movefile command doesn't move the subdirectories or their contents, and the clip ERRORS.

I've tried using ^!IfError to run a subroutine to collect a list of these subdirectories and then continue. Should I be using DOS commands through the shell, or a PERL script instead?
--
ALi


Art Kocsis
 

On 06-27-2020 06:21, Ali Kayn wrote:
Not all the directories are empty, some of them have subdirectories. The movefile command doesn't move the subdirectories or their contents, and the clip ERRORS.

I've tried using ^!IfError to run a subroutine to collect a list of these subdirectories and then continue. Should I be using DOS commands through the shell, or a PERL script instead?
Yes. While NTB is a flexible language and great for creating/editing file system commands, it is not well suited for executing the commands themselves. Either use NTB to create batch commands to run under windows or use the ^!DOS command within a NTB clip. The ^!Wait command is usually required as NTB does not wait for a ^!DOS command to complete before continuing a clip.

e.g.
^!DOS Rename x:\Path\OldName\ NewName
^!WAIT

If you want to monitor the command's stdout or stderr, use ^$GetOutput instead of ^!DOS

^!Set %stdout%=^$GetOutput(Rename x:\Path\OldName\ NewName)$
^!WAIT

Note the trailing backslash on "OldName" is required to tell CMD.EXE that "OldName" is a directory name, not a filename.

Use ^$GetFiles([+]FilePath;FileSpecs[;Attr][;SortingOrder])$ to build a directory tree
Note: Double quotes are required if the "+" recursion option is used

^!SetListDelimiter ^P
^!SetArray %flist%=^$GetFiles("+D:\Wintemp\$Test\";*.*)$
^!Info ^%flist%

Art