Thanks Tim,

I wrote code to use MOVE DOCUMENT and CREATE FOLDER to do this.
It works, it is (on my tests, NOT very deep folder structures) quick.

So - Folder_Rename(Old_Folder_Path;New_Folder_Name)
works, no problem.

Then I tried to change the case, rather then rename on a folder and hit 
a wall...
Folder_Rename(Old_Folder_Path;OLD_FOLDER_NAME)

FAIL!
folder already exists.... of course it does!!! as the OS is case blind, 
unless you are one of the few masochists out there running OSX with 
case sensitivity turned on.

this is where I stopped today...

I will try your code, I suspect that it will work even with a case 
change, as this is occurring at the OS level, rather then 4D.

Thanks again


On Fri, 20 Oct 2017 15:07:23 -0500, Tim Nevels via 4D_Tech wrote:
> On Oct 20, 2017, at 1:04 PM, Chip Scheide wrote:
> 
>> I want to rename a directory, from say New Folder -> New Folder too
>> Move Document complains, as neither the source nor the destination are 
>> documents.
>> 
>> is there another means to rename a folder other than:
>> 
>> - Create new folder with new/changed name
>> - copy all contents from source folder to destination
>> - delete original
>> 
>> -repeat for all sub directories of the original source)
>> 
>> seems like an excessive amount of work for a change to a directory 
>> name.....
> 
> It is an excessive amount of work. We need a native RENAME FOLDER 
> command or a MOVE FOLDER command. I don’t think it makes sense to 
> make the MOVE DOCUMENT command also work with folders. It needs to be 
> a separate command.
> 
> So I had to write my own RenameFolder command. Here it is Chip:
> 
>   // ===========================================
>   // PROJECT METHOD: RenameFolder
> 
>   // PARAMETERS: $0 = error message
>   // $1 = path to folder
>   // $2 = new folder name
> 
>   // DESCRIPTION: Renames a folder by calling the operating system
>   // to do the work. If rename was successful return blank; otherwise
>   // return error message text.
> 
>   // CREATED BY: Tim Nevels, Innovative Solutions ©2017
>   // DATE: 4/28/17
>   // LAST MODIFIED: 
>   // ============================================
> 
> C_TEXT($0;$errorStream_t)
> C_TEXT($1;$folderPath_t)
> C_TEXT($2;$newFolderName_t)
> $folderPath_t:=$1
> $newFolderName_t:=$2
> 
> C_TEXT($destinationFolderPath_t;$command_t;$inputStream_t;$outputStream_t)
> 
>   // setup environment
> SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")
> SET ENVIRONMENT 
> VARIABLE("_4D_OPTION_BLOCKING_EXTERNAL_PROCESS";"true")  // wait for 
> it to finish
> 
> $destinationFolderPath_t:=GetParentDirectoryPath 
> ($folderPath_t)+$newFolderName_t
> 
> Case of 
>    : (Test path name($folderPath_t)#Is a folder)  //  check if  
> folder exists
>       $errorStream_t:="folder does not exist"
> 
>    : (Test path name($destinationFolderPath_t)=Is a folder)  //  
> check if destination folder name already exists
>       $errorStream_t:="folder already exists"
> 
>    : (<>macOS)
>       $command_t:="mv "+GetPOSIXfilePath ($folderPath_t)+" 
> "+GetPOSIXfilePath ($destinationFolderPath_t)
>       LAUNCH EXTERNAL 
> PROCESS($command_t;$inputStream_t;$outputStream_t;$errorStream_t)
> 
>    Else   // Windows
>       $command_t:="cmd.exe /C rename "+Char(Double 
> quote)+$folderPath_t+Char(Double quote)+" "+Char(Double 
> quote)+$newFolderName_t+Char(Double quote)
>       LAUNCH EXTERNAL 
> PROCESS($command_t;$inputStream_t;$outputStream_t;$errorStream_t)
> End case 
> 
>   // return result
> $0:=$errorStream_t
> 
> 
> Tim
> 
> ********************************************
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> timnev...@mac.com
> ********************************************
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to