Champ MUC
asked on
How to rename a file with this format DDMMYYY_HHam/pm_Filename.xls <----- Date and time is converted from SGT to GMT
Hi Experts,
I just wan to seek help, im not really a programmer but I came across the need for this for one project. Is there a way for a batch file or script to rename a file with the format like this DDMMYYY_HHam/pm_Filename.x ls (am/pm is interchangeable), the tricky part is the date and time should be converted to GMT Timezone, I am on SGT timezone right now so I cannot use the time from my local machine.
I'm using this script to rename it but I'm having issues with the date and time changing from single digit to double digit which requires the percentage % to be change.
@echo off
set TmpFile="%temp%.\tmp.vbs"
echo> %TmpFile% n=Now
echo>>%TmpFile% s=DateAdd("h", -7, n)
echo>>%TmpFile% Wscript.Echo "set ireland7=" ^& s
cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
call "%temp%.\tmp.bat"
del "%temp%.\tmp.bat"
del %TmpFile%
copy "D:\Data\Hourly_Report\Hou rlyFile\vo ucher_last _hour.xls" "D:\Data\Hourly_Report\%ir eland7:~0, 2%-%irelan d7:~3,1%-% ireland7:~ 5,4%_%irel and7:~10,2 %%ireland7 :~19,17%_H ourly_Repo rt.xls"
Thanks in advance!! :)
I just wan to seek help, im not really a programmer but I came across the need for this for one project. Is there a way for a batch file or script to rename a file with the format like this DDMMYYY_HHam/pm_Filename.x
I'm using this script to rename it but I'm having issues with the date and time changing from single digit to double digit which requires the percentage % to be change.
@echo off
set TmpFile="%temp%.\tmp.vbs"
echo> %TmpFile% n=Now
echo>>%TmpFile% s=DateAdd("h", -7, n)
echo>>%TmpFile% Wscript.Echo "set ireland7=" ^& s
cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
call "%temp%.\tmp.bat"
del "%temp%.\tmp.bat"
del %TmpFile%
copy "D:\Data\Hourly_Report\Hou
Thanks in advance!! :)
I don't know the complete answer to your question but I do know that using 'DDMMYYY' format will not sort in date order. I use 'YYYYMMDD' when I need the names to sort properly.
ASKER
Hi Dave,
Thanks, format is not really a big issue at all, only the date and time should be in Irish time (Another Timezone) and if possible, can you teach me how to set format of date and time to 2 digits? I am getting 1/6/2017 6AM, I want something like 01/06/2017 06AM..
Thanks
Thanks, format is not really a big issue at all, only the date and time should be in Irish time (Another Timezone) and if possible, can you teach me how to set format of date and time to 2 digits? I am getting 1/6/2017 6AM, I want something like 01/06/2017 06AM..
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.