Tech Tip: Renaming a Windows directory with LAUNCH EXTERNAL PROCESS
PRODUCT: 4D | VERSION: 11.6 | PLATFORM: Win
Published On: June 24, 2010
A quick and easy way to rename Windows directories is to use the LAUNCH EXTERNAL PROCESS command.
The following code demonstrates how to rename "MyOldFolder" located on drive D:\ to "MyNewFolder".
C_TEXT($source;$target) $source:="MyOldFolder" $target:="MyNewFolder" `Hide the Command prompt SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"TRUE") `Set the drive where the external process is going to be launched SET ENVIRONMENT VARIABLE("_4D_OPTION_CURRENT_DIRECTORY";"D:\\") `Launch the process to rename the file LAUNCH EXTERNAL PROCESS("cmd.exe /C ren "+$source+" "+$target) |
The string "cmd.exe /C ren" starts the Command prompt , executes the ren command and closes it.
The syntax of the ren command is:
ren [drive:][path]source_file/directory target_file/directory