Copy link to clipboard
Copied
Hi, I'm a bit stuck with a script, I'm completely new to scripting.
I need photoshop to
Locate a folder
Ask me for a new folder name
rename the folder
Locate another folder
Rename that folder with the same folder name
The folder it needs to locate will ALWAYS be the same.
I know this seems very simple, but I'm a complete newbie.
I can't find anything in the community that tells me how to get the script to ask me for the folder name I'd like to rename to.
Thanks,
Darren
Perhaps try absolute URI format:
'/c/users/daz10/Desktop/Temp/OldFolderName'
Or relative:
'~/Desktop/Temp/OldFolderName'
Copy link to clipboard
Copied
hello @Darren5EBE,
Give this a try as a stating point....you should put in checks to making sure the two folders are not in the same location.
var myFolder = Folder.selectDialog ("Select folder to rename");
if (myFolder != null){
}else{
exit();
}
var myNewFolderName = prompt("Enter new folder name","");
if(myNewFolderName == null)
{
exit();
}
if(myNewFolderName == "")
{
alert ("Error!\nNo new folder name entered.");
exit();
}
myFolder.rename(myNewFolderName);
var myNextFolder = Folder.selectDialog ("Select the next folder to rename");
if (myNextFolder != null){
}else{
exit();
}
myNextFolder.rename(myNewFolderName);
Regards,
Mike
Copy link to clipboard
Copied
Hi Mike,
Your script worked perfectly, my requirement is a little different, I tried to tweak your code but just can't get it to work, The folder I'm trying to rename will always be the same path, it's part of a longer script that I'm trying to cobble together.
Can you advise why it won't rename the folder? Your help is much appreciated. Thankyou.
Copy link to clipboard
Copied
The code you posted works for me on a Mac... The only change I made was to a cross platform relative path for the folder:
var myFolder = Folder('~/Desktop/test');
Copy link to clipboard
Copied
Hello @Darren5EBE,
Sorry I'm a Mac user.....See if this works for you...
var myFolder = Folder('D:/Users/daz10/Desktop/Temp/OldFolderName');
if (myFolder != null){
}else{
exit();
}
var myNewFolderName = prompt("Enter new folder name","");
if(myNewFolderName == null)
{
exit();
}
if(myNewFolderName == "")
{
alert ("Error!\nNo new folder name entered.");
exit();
}
myFolder.rename(myNewFolderName);
Regards,
Mike
Copy link to clipboard
Copied
Perhaps try absolute URI format:
'/c/users/daz10/Desktop/Temp/OldFolderName'
Or relative:
'~/Desktop/Temp/OldFolderName'
Copy link to clipboard
Copied
Worked perfectly, thkyou