Rename Files with Consecutive Numbers?
Moderators: Dorian (MJT support), JRL
Rename Files with Consecutive Numbers?
Hi,
I LOVE the record feature for creating scripts! But, unless I want to manually go through the process of a WHOLE script, I'm not sure how to use it in this case.
What I'm trying to do is rename files with consecutive numbers. The script I recorded is this:
___________________________________________________
//Recorded Events
Let>WW_TIMEOUT=5
CapsOff
Press NP1
Wait>0.22
Press NP0
Wait>0.23
Press NP4
Wait>0.59
Send>.jpg
Wait>0.63
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>0.65
Press NP1
Wait>0.17
Press NP0
Wait>0.22
Press NP5
Wait>0.42
Send>.jpg
Wait>0.25
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>0.4
Press NP1
Wait>0.19
Press NP0
Wait>0.24
Press NP6
Wait>0.19
Send>.jpg
Wait>0.25
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>4.01
Press CTRL
Wait>0.7
Press ALT
Wait>0.27
Send>x
Wait>0.02
Release CTRL
Wait>0.02
Release CTRL
Wait>0.67
MouseMove>738,761
Wait>2.49
LClick
Wait>0.21
LDown
WaitWindowOpen>Macro Scheduler 7.2
MoveWindow>Macro Scheduler 7.2,183,53
ResizeWindow>Macro Scheduler 7.2,808,574
Wait>0.14
_____________________________________________
The NP1 NP0 NP6 is where I typed in numbers. I'm trying to name all of the files in this directory 101-201 .jpg. Is there a way to tell it after the first one (101.jpg) to keep going consecutively until it reaches (201.jpg) ?
(Special note for those who catch on that I'm using 'Press Down' to get from one file name to the next. You may be confused since this doesn't work in Microsoft Windows folders. It works in this case because I'm doing the renaming in a FrontPage folder, which thankfully supports the arrow down to put you into the 'rename' of the next file listed.)
I LOVE the record feature for creating scripts! But, unless I want to manually go through the process of a WHOLE script, I'm not sure how to use it in this case.
What I'm trying to do is rename files with consecutive numbers. The script I recorded is this:
___________________________________________________
//Recorded Events
Let>WW_TIMEOUT=5
CapsOff
Press NP1
Wait>0.22
Press NP0
Wait>0.23
Press NP4
Wait>0.59
Send>.jpg
Wait>0.63
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>0.65
Press NP1
Wait>0.17
Press NP0
Wait>0.22
Press NP5
Wait>0.42
Send>.jpg
Wait>0.25
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>0.4
Press NP1
Wait>0.19
Press NP0
Wait>0.24
Press NP6
Wait>0.19
Send>.jpg
Wait>0.25
Press Down
WaitWindowOpen>Rename
MoveWindow>Rename,312,292
ResizeWindow>Rename,401,157
WaitWindowOpen>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment
MoveWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,-4,-4
ResizeWindow>Microsoft FrontPage - \\Brettdell\documents\Manak Enterprises\My Webs\All That Entertainment,1032,748
Wait>4.01
Press CTRL
Wait>0.7
Press ALT
Wait>0.27
Send>x
Wait>0.02
Release CTRL
Wait>0.02
Release CTRL
Wait>0.67
MouseMove>738,761
Wait>2.49
LClick
Wait>0.21
LDown
WaitWindowOpen>Macro Scheduler 7.2
MoveWindow>Macro Scheduler 7.2,183,53
ResizeWindow>Macro Scheduler 7.2,808,574
Wait>0.14
_____________________________________________
The NP1 NP0 NP6 is where I typed in numbers. I'm trying to name all of the files in this directory 101-201 .jpg. Is there a way to tell it after the first one (101.jpg) to keep going consecutively until it reaches (201.jpg) ?
(Special note for those who catch on that I'm using 'Press Down' to get from one file name to the next. You may be confused since this doesn't work in Microsoft Windows folders. It works in this case because I'm doing the renaming in a FrontPage folder, which thankfully supports the arrow down to put you into the 'rename' of the next file listed.)
Yarrielle
I'm way too stupid for this!
I'm way too stupid for this!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This is untested, but should do what you want. Modify paths to suit.
Code: Select all
GetFileList>c:\folder\*.jpg,filelist
Separate>filelist,;,files
Let>start=100
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=files_%k%
Let>newname=start+k
MoveFile>this_file,c:\folder\%newname%.jpg
Until>k=files_count
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hello, and thank you. It looks so simple when you do it.
However, I finally had a chance to try this out tonight.
I tried changing the lines with C:\folder... to the actual directory and running it again. I got the error 'Error: Label not found!'
Now I'm wondering what I was supposed to do with that snippet you gave me that I didn't do. I have no doubt that the error lies with me...I'm such a noobie at this.
And...Does it matter that the folder I'm accessing is over a network, which causes the path to show up like \\Path\blah\blah ?
Thanks
However, I finally had a chance to try this out tonight.
I tried changing the lines with C:\folder... to the actual directory and running it again. I got the error 'Error: Label not found!'
Now I'm wondering what I was supposed to do with that snippet you gave me that I didn't do. I have no doubt that the error lies with me...I'm such a noobie at this.
And...Does it matter that the folder I'm accessing is over a network, which causes the path to show up like \\Path\blah\blah ?
Thanks
Yarrielle
I'm way too stupid for this!
I'm way too stupid for this!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
No, it does not matter if you use a network path. That is fine.
The Label not found error cannot be coming from the GetFileList command. There must be something else wrong with your script.
Please use the debugger to find the line that causes the error:
http://www.mjtnet.com/blog/2006/05/17/use-the-debugger/
If you are still none the wise, post your script here. We cannot help much if we can't see your code.
The Label not found error cannot be coming from the GetFileList command. There must be something else wrong with your script.
Please use the debugger to find the line that causes the error:
http://www.mjtnet.com/blog/2006/05/17/use-the-debugger/
If you are still none the wise, post your script here. We cannot help much if we can't see your code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi, I'm finally back again. (I didn't see this response...Guess I forgot to suscribe to this, sorry.)
Here is my code, but I'm so confused now. I think what I've done is taken what you gave me and nothing else and tried to make that work. I'm not sure. Here is what I have:
GetFileList>C:\Documents and Settings\Becky Manak\Desktop\Current\*.jpg,filelist
Separate>filelist,;,files
Let>start=100
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=files_%k%
Let>newname=start+k
MoveFile>this_file,C:\Documents and Settings\Becky Manak\Desktop\Current\%newname%.jpg
Until>k=files_count
I see that there is no rename command in there at all. I can only assume I messed up and took that out. Now I'm not sure where to put it.
Also, I did run the debugger. On the very last line it told me 'Error - Label not found' But all the other lines acted like they were working.
Thanks for your time on this; I hope I'm not a hopeless case!
Here is my code, but I'm so confused now. I think what I've done is taken what you gave me and nothing else and tried to make that work. I'm not sure. Here is what I have:
GetFileList>C:\Documents and Settings\Becky Manak\Desktop\Current\*.jpg,filelist
Separate>filelist,;,files
Let>start=100
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=files_%k%
Let>newname=start+k
MoveFile>this_file,C:\Documents and Settings\Becky Manak\Desktop\Current\%newname%.jpg
Until>k=files_count
I see that there is no rename command in there at all. I can only assume I messed up and took that out. Now I'm not sure where to put it.
Also, I did run the debugger. On the very last line it told me 'Error - Label not found' But all the other lines acted like they were working.
Thanks for your time on this; I hope I'm not a hopeless case!
Yarrielle
I'm way too stupid for this!
I'm way too stupid for this!
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
MoveFile> does the rename, from the program help:
MoveFile>sourcefile,destinationfile
Moves the file (or files), sourcefile, to the file (or files) destinationfile.
sourcefile, and destination_path may be variables. Wildcards can be used.
To make MoveFile perform a simple Rename function, rather than physically moving the entire file, set MF_RENAME to 1.
MoveFile>sourcefile,destinationfile
Moves the file (or files), sourcefile, to the file (or files) destinationfile.
sourcefile, and destination_path may be variables. Wildcards can be used.
To make MoveFile perform a simple Rename function, rather than physically moving the entire file, set MF_RENAME to 1.
Re:
what if you're trying to pull *.jpg and *.gif as well? how do you add that in there?Marcus Tettmar wrote:This is untested, but should do what you want. Modify paths to suit.
Code: Select all
GetFileList>c:\folder\*.jpg,filelist Separate>filelist,;,files Let>start=100 Let>k=0 Repeat>k Let>k=k+1 Let>this_file=files_%k% Let>newname=start+k MoveFile>this_file,c:\folder\%newname%.jpg Until>k=files_count
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Rename Files with Consecutive Numbers?
A simple way would be just to run that code twice, for each filetype. Make it a subroutine. Call it for each filetype you want.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?