Skip to main content
Inspiring
January 29, 2013
Question

Move a folder

  • January 29, 2013
  • 1 reply
  • 3312 views

Hi

I´d like to write a script that is able to copy (preferred) or move a folder from a place to another. target is #estoolkit

In the JavaScript Tools Guide.pdf I do not see any method for copying or moving folders. The copy() function works only for Files, not Folders.

Is it possible to copy or move a folder (for example ~/Desktop/myFolder) to another place (for example ~/Desktop/Destination)

Thank you for the tip

Best Regards

Gustavo.

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Brainiac
January 29, 2013

The Object Model Viewer lists a method changePath for Folders, have you tried that?

Inspiring
January 29, 2013

If you want to be safe and use copy instead of move you need to use getFiles on the target folder. Copy each file checking it copied. Only if it did copy do you delete.

But I think as long as both paths are on the same drive and you want to move all the files in a folder, using changePath is safe.

Paul Riggott
Inspiring
January 30, 2013

As noted, a Folder object doesn't have a copy() method. So no, I can not move a folder that way. But the code I posted moves all the files in a folder. You could add a flag for failed copy and remove the folder if all the files were moved.

I would think there is a Reason Adobe doesn't have a folder.copy() or move() methods and the documentation doesn't say rename() moves the file/folder and the argument should only be the newName without a path.

rename() may work most of the time. It may even rarely fail. I just wonder that it could fail is the reason it's not documented and Adobe doesn't have a move() method. Something goes wrong during the move could result in lost data.


You could well be right Mike.

I would recommend that tests are done on the system you are going to apply it on before using in anger.