Page 1 of 1
Need a Script.
Posted: 13 Oct 2009 03:11
by Member
Could someone help me with a script that would do something like this:
o1. Select all files that needs to be renamed.
o2. A window pops up asking to input Beginning Increment Renaming Value.
o3. Adds a period after the Increment.
o4. A window pops up asking for a new filename.
o5. Keeps the extension as is.
o6. Make everything lowercase.
o7. Starts the renaming.
The before and After result would look something like this:
Before:
awedaefa.txt
rgaweW.TXT
SAWESFAER.txt
wefesrgg.txt
eartgear.txt
thserger.txt
After:
00001.samplefile.txt
00002.samplefile.txt
00003.samplefile.txt
00004.samplefile.txt
00005.samplefile.txt
00006.samplefile.txt
P.S. what's the command to "changes all space to ."
i noticed that XYplorer already has the "change all spaces to _" but I need the "." instead.
TIA
Re: Need a Script.
Posted: 13 Oct 2009 04:47
by serendipity
Member wrote:Could someone help me with a script that would do something like this:
o1. Select all files that needs to be renamed.
o2. A window pops up asking to input Beginning Increment Renaming Value.
o3. Adds a period after the Increment.
o4. A window pops up asking for a new filename.
o5. Keeps the extension as is.
o6. Make everything lowercase.
o7. Starts the renaming.
The before and After result would look something like this:
Before:
awedaefa.txt
rgaweW.TXT
SAWESFAER.txt
wefesrgg.txt
eartgear.txt
thserger.txt
After:
00001.samplefile.txt
00002.samplefile.txt
00003.samplefile.txt
00004.samplefile.txt
00005.samplefile.txt
00006.samplefile.txt
Hi and Welcome!
Here is a simple script:
Code: Select all
//Enter increment
input $increment, "Enter Increment value", 000001;
//Enter filename
input $name, "Enter file name", name;
//Rename command
rename b, "<#$increment>.$name";
//Convert all to lowercase
#127;
Member wrote:
P.S. what's the command to "changes all space to ."
i noticed that XYplorer already has the "change all spaces to _" but I need the "." instead.
TIA
Code: Select all
//rename (with preview) space to .
rename s, " /.", p;
Re: Need a Script.
Posted: 13 Oct 2009 06:01
by Member
Wow, thank you so much serendipity.
It works like a charm. I was trying to figure it out myself, yet you make it look so simple.
May I ask where did #127 come from? Or what it's called.
Edit: Nevermind, it's called a Command ID.
Re: Need a Script.
Posted: 13 Oct 2009 09:58
by j_c_hallgren
Member wrote:Wow, thank you so much serendipity.
It works like a charm. I was trying to figure it out myself, yet you make it look so simple.
Hi and another welcome to the XY forums! And thanks again for making that change to your ID!
I started looking at what you wanted and then realized that I didn't know scripting enough to answer but figured one of our experts would do so, and as you saw, serendipity did...I'm better at handing the more mundane queries here and such...but together, we all hopefully provide what others need, whether they be first-timers or regulars.
Re: Need a Script.
Posted: 13 Oct 2009 15:53
by Member
j_c_hallgren wrote:Member wrote:Wow, thank you so much serendipity.
It works like a charm. I was trying to figure it out myself, yet you make it look so simple.
Hi and another welcome to the XY forums! And thanks again for making that change to your ID!
I started looking at what you wanted and then realized that I didn't know scripting enough to answer but figured one of our experts would do so, and as you saw, serendipity did...I'm better at handing the more mundane queries here and such...but together, we all hopefully provide what others need, whether they be first-timers or regulars.
Definitely, thanks
j_c_hallgren for the kind welcome and assistance even though I am a new member. I have to say, this is a great community and a very good resource area. Keep up the great work you guys!
Edit:
Could someone further help me on this script? I was wondering how I can make the script below to perform on sub directories and files as well. Again, thanks to
serendipity I can understand how the script works. Don't laugh because I know the script is a mess, but it works. Lol.
Code: Select all
//Replace dashes ( - ) to period ( . )
rename s, "-/.";
//Replace underlines ( _ ) to period ( . )
rename s, "_/.";
//Replace commas ( , ) to period ( . )
rename s, ",/.";
//Replace spaces to period ( . )
rename s, " /.";
//Replace quintuple periods ( ..... ) to period ( . )
rename s, "...../.";
//Replace quadruple periods ( .... ) to period ( . )
rename s, "..../.";
//Replace triple periods ( ... ) to period ( . )
rename s, ".../.";
//Replace double periods ( .. ) to period ( . )
rename s, "../.";
//Convert all to lowercase
#127;
Re: Need a Script.
Posted: 14 Oct 2009 13:56
by Muroph
Member wrote:Could someone further help me on this script? I was wondering how I can make the script below to perform on sub directories and files as well.
i haven't tested it, but this
should work on all files and sub-dirs of the current folder.
Code: Select all
#263; //show all items in branch
sel a; //select all items
setting RegexpRenameSep,'>>';
rename r,'[_, -]|\.{2,}>>.';
#127; //Convert all to lowercase
all those rename commands were replaced by a single regex.
the script will also replace more than 5 consecutive periods.
Re: Need a Script.
Posted: 15 Oct 2009 03:12
by Member
Muroph wrote:Member wrote:Could someone further help me on this script? I was wondering how I can make the script below to perform on sub directories and files as well.
i haven't tested it, but this
should work on all files and sub-dirs of the current folder.
Code: Select all
#263; //show all items in branch
sel a; //select all items
setting RegexpRenameSep,'>>';
rename r,'[_, -]|\.{2,}>>.';
#127; //Convert all to lowercase
all those rename commands were replaced by a single regex.
the script will also replace more than 5 consecutive periods.
Hello
Muroph,
I tried that script but it doesn't work. A lot of the sub files and folders are randomly named correctly as well as not being named at all. I like your approach to this script... Showing all items in a branch and then renaming them. I'll take a look at the code and see if I can rework it, although it'll be be hard for someone without any scripting knowledge. Thanks again
Muroph.