For a long time i am looking for a tool that help’s me to facilitate a very cumbersome task. So I bought macro scheduler.
The task seems easy but I don’t find a way to automate this.
From time to time I have to replace a load of application-files with the newest version of the same file. The files to be replaced are spread all over the computer and have different names, but the names allways end with the same three letters “absâ€
Replace files and rename the new files
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Can you clarify - does the filename end in abs or is the extension abs? Or both? Is the file 788.abs or 788abs.??? It is not clear from your description.
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?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Pretty sure this is what you want:
It may need tweaking as I may not quite have understood your exact requirements, but it should get you started. You may need to change the "c:\*.abs" part to suit the filespec you are searching for. Also don't forget to modify the first line to tell the script where the new abs file is that you want to replace the found files with.
Code: Select all
//Define where the new file is stored here:
Let>new_source_file=c:\the_new_file\abs.abs
//Get list of all matching files. Modify filespec accordingly.
Let>RP_WINDOWMODE=0
Let>RP_WAIT=1
Run>cmd.exe /c dir /b /s c:\*.abs >> %TEMP_DIR%\findresults.txt
//read results list into memory - this is a list of matching files
ReadFile>%TEMP_DIR%\findresults.txt,file_list
Separate>file_list,CRLF,file_array
//loop through file list and process each one
If>file_array_count>0
Let>x=0
Repeat>x
Let>x=x+1
Let>this_file=file_array_%x%
//now we can do what you need to do to the file here. If I understand you correctly all you need
//to do is copy the new file to the same name as the old file, overwriting it in the process:
Let>CF_OVERWRITE=1
CopyFile>%new_source_file%,this_file
Until>x=file_array_count
Endif
DeleteFile>%TEMP_DIR%\findresults.txt
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?
Sorry, my english is only very basic.mtettmar wrote:Can you clarify - does the filename end in abs or is the extension abs? Or both? Is the file 788.abs or 788abs.??? It is not clear from your description.
The filenames end in abs and the extension is allways apr; i.e. 788abs.apr
Thank you very much for your input, much appreciated. I will give it a try.
Matthias
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
So this should work for you:Schtürmi wrote:mtettmar wrote:The filenames end in abs and the extension is allways apr; i.e. 788abs.apr
Code: Select all
//Define where the new file is stored here:
Let>new_source_file=c:\the_new_file\abs.apr
//Get list of all matching files. Modify filespec accordingly.
Let>RP_WINDOWMODE=0
Let>RP_WAIT=1
Run>cmd.exe /c dir /b /s c:\*abs.apr >> %TEMP_DIR%\findresults.txt
//read results list into memory - this is a list of matching files
ReadFile>%TEMP_DIR%\findresults.txt,file_list
Separate>file_list,CRLF,file_array
//loop through file list and process each one
If>file_array_count>0
Let>x=0
Repeat>x
Let>x=x+1
Let>this_file=file_array_%x%
//now we can do what you need to do to the file here. If I understand you correctly all you need
//to do is copy the new file to the same name as the old file, overwriting it in the process:
Let>CF_OVERWRITE=1
CopyFile>%new_source_file%,this_file
Until>x=file_array_count
Endif
DeleteFile>%TEMP_DIR%\findresults.txt
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?