Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Wisescript : Rename file action

Updated: 21 May 2010 | 5 comments
Dhanya's picture
0 0 Votes
Login to vote
This issue has been solved. See solution.

Hi,

I have to copy the log files to a 'logs' folder and maintain the older versions of the file with SYSDATE appended to filename. I am trying to use the Rename File/Directory action after the copy, but it just does not seem to work. I give the complete path name in the old path field, and just the new 'filename-%SYSDATE%.log' as the new file name, where SYSDATE is the variable that holds the system date.

Please let me know where have I gone wrong and is there any workarounds.

TIA,
Dhanya

discussion Filed Under:

Comments

EdT's picture
09
Oct
2009
0 Votes 0
Login to vote

Try hard coding the new name

Try hard coding the new name as a test, and see if the rename then works. I'm not sure that you can use variables to set the new filename, so hard coding the new filename rather than using a variable will at least let us know if your code is basically working OK.

You could also attach your WSE code to your first posting for us to look at

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

lwajswaj's picture
09
Oct
2009
1 Vote +1
Login to vote

I think the problem is your

I think the problem is your using SYSDATE which might contain invalid character for a filename. Remember, Windows doesn't support \ / : * ? " < > | for file names.... so if your date follows the format: Month/Day/Year, you won't be able to rename the files. You'll have to use some format like YearMonthDay all together.

Try using the date without invalid characters, you can use Parse string Action to split the SYSDATE on "/". Something like this:

item: Get System Information
  Variable=SYSDATE
end
item: Parse String
  Source=%SYSDATE%
  Pattern=/
  Variable1=MONTH
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=/
  Variable1=DAY
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=
  Variable1=YEAR
  Variable2=TEMP
  Flags=00000001
end
item: Set Variable
  Variable=SYSDATE
  Value=%YEAR%%MONTH%%DAY%
end

Hope this helps,

Dhanya's picture
13
Oct
2009
1 Vote +1
Login to vote

lwajswaj,

Thanks for the idea lwajswaj, but it still does not work.
Ed,
I am trying to rename Installation.log which is placed in a folder 'logs'. The script is executed from the same dir where the logs folder is present.
I tried it by hardcoding the new file name, no change!
Here is my script:

item: Get System Information
  Variable=SYSDATE
end
item: Parse String
  Source=%SYSDATE%
  Pattern=/
  Variable1=MONTH
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=/
  Variable1=DAY
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=
  Variable1=YEAR
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=:
  Variable1=HH
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=:
  Variable1=MM
  Variable2=TEMP
  Flags=00000001
end
item: Parse String
  Source=%TEMP%
  Pattern=:
  Variable1=SS
  Variable2=TEMP
  Flags=00000001
end
item: Set Variable
  Variable=SYSDATE
  Value=%DAY%_%MONTH%_%YEAR%_%HH%_%MM%_%SS%
end
item: Set Variable
  Variable=LOG
  Value=logs
end
item: Rename File/Directory
  Old Pathname=%LOG%\Installation.log
  New Filename=Installation_%SYSDATE%.log
end

 

EdT's picture
13
Oct
2009
1 Vote +1
Login to vote

Whoops

Looking at your code segment, are you trying to rename the installation log of the installation that is currently running? If that is the case then it definitely will not work.

Also looking at your code - you are setting the variable %LOGS% to the string "logs"

You are then trying to run the command "Rename File/Directory" with the old pathname set to "logs\installation.log"

This is an incomplete path. You cannot rely on the current working directory being set to any particular value - it could be C:\ or it could be Z:\abc\def. Unless you provide a FULL and COMPLETE path for the Rename File/Directory command, you cannot rely on it working.

Of course, there may be some code that you have not included which addresses these issues, but that would be my starting point for getting this working.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Dhanya's picture
21
Oct
2009
0 Votes 0
Login to vote

Solved

You are right Ed and lwajswaj...

A complete path is required, along with a sys date minus any special characters.
Thanks guys!

P.s: I want to mark both your comments as solutions...but it allows only once...