Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


JeanetteW
2008-07-23T16:15:28Z
I want to setup a task that renames a group of files (The file names are the same but differenct ext.) by adding the current date to the file name. Does anyone have examples of how to do this? So far what I have tried is
Example
Old File path: c:\acknowledgements\filename.*
New File path: c:\acknowledgements\save\filename{DATETIME()}.*

Thanks
Sponsor
Forum information
Support
2008-07-23T17:21:39Z
We are working on a new version of file renaming which allows multiple files at a time. There is however a better solution which involves pushing instead of polling. That solution consists of using a File Trigger instead. You watch a folder then use the result that contains the path and filename.

Once you have created a Job with a File Trigger you can add a Rename Task. Click on the Variables button on the Task to bring up the Variables. You can browse through the VisualCron variables to find the correct Variables.

For source file I would use:

{TRIGGER(Active,LastTrigger,File.Result.FullPath)} - which is the full path to the new file.

For destination file I would use a combination of Variable functions and Variables:

{TRIGGER(Active,LastTrigger,File.Result.Folder)}\{PATH(GetFileNameWithoutExtension,{TRIGGER(Active,LastTrigger,File.Result.Name)})}{DATEFORMAT(MMddyyyy)}{PATH(GetExtension,{TRIGGER(Active,LastTrigger,File.Result.Name)})}

First part of the destination file name retrieves the folder name. Second part retrives the filename without the extension (based on the file name) as you want to place the date after the file name and before the extension. After that we use date format. Don't use DATETIME() here as it may contain invalid characters for a filename. After that, we add the extension again based on the file name.

Hope this helps!
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
JeanetteW
2008-07-23T21:50:21Z
Sorry, I am new to this product and need you to simplify this some more for me.
I created the File Trigger and set to the appropriate directory, watching for file creation.

Now I need to create a Rename Task and copy {TRIGGER(Active,LastTrigger,File.Result.FullPath)} into the Source path? Do I need to modify this statement any or does it pull the information from the trigger?

Same with the destination line, {TRIGGER(Active,LastTrigger,File.Result.Folder)}\{PATH(GetFileNameWithoutExtension,{TRIGGER(Active,LastTrigger,File.Result.Name)})}{DATEFORMAT(MMddyyyy)}{PATH(GetExtension,{TRIGGER(Active,LastTrigger,File.Result.Name)})}, do I need to modify anything within this string?

Thank you.
Support
2008-07-23T21:51:43Z
You can use it as written if you have setup the Trigger on the Job.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
JeanetteW
2008-07-23T23:33:10Z
It worked, the only thing was that multiple files were written at the same time but only one of the files got renamed. How do I ensure all the file are renamed?
Support
2008-07-23T23:36:19Z
You probably have to uncheck "Don't start if Job is already running" on the main page of Job settings.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
ErikC
2008-07-24T08:25:17Z
You can also run a batch file doing this for you.

FOR /f "tokens=*" %%i IN ('dir /b c:\acknowledgements\%1.*') DO (
	FOR /f "tokens=1,2 delims=." %%a IN ("%%i") DO (
		REN "c:\acknowledgements\%%a.%%b" "%%a%2.%%b"
		MOVE "c:\acknowledgements\%%a%2.%%b" "c:\acknowledgements\save\"
	)
)


Run this batch file with two parameters:
The 1st parameter is de filename you are looking for in the c:\acknowledgements directory without the extention.
The 2nd parameter is the date value you can create with the visualcron variables, f.e. {DATEFORMAT(yyyyMMdd)}.

This batch file will look for every file in the c:\acknowledgements dir looking for matching files.
If it has found a file it wil rename it to a new name including the date part and after that it will move it to the save dir.

You might have solved your issue already, if not... try this one 🖐
Uses Visualcron since 2006.
Scroll to Top