2 Replies - 294 Views - Last Post: 06 July 2013 - 01:36 AM Rate Topic: -----

#1 ZickZak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-July 13

Batch - rename to #ofWeek

Posted 05 July 2013 - 02:03 PM

I've got a batch to rename a file to "Date #ofWeekofYear.week heyheyhey" (the heyheyhey is a placeholder)
What it does is it renames the file like this, atm : "..--502.week heyheyhey" and says "missing operand". Can you please fix this for me?

Thanks ;)/>

@echo off
for /F "tokens=1-5 delims=/" %%d in ("%date%") do (
   set ddmmyy=%%e.%%f.%%g
   set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1
)
rem Get Julian Day Number of today's date
if %mm% lss 3 set /A mm+=12, yy-=1
set /A a=yy/100, b=a/4, c=2-a+b, e=36525*(yy+4716)/100, f=306*(mm+1)/10, 

jdn=c+dd+e+f-1524
rem Subtract Julian Day Number of January/1st (get number of days in year)
set /A a=yyM1/100, b=a/4, c=2-a+b, e=36525*(yyM1+4716)/100, f=306*14/10, 

days=jdn-(c+1+e+f-1524)+1
rem Get number of week
set /A week=(days+3)/7+1
rename "C:\TEST\1.txt" "%ddmmyy%-%week%.week heyheyhey.txt"
pause


Is This A Good Question/Topic? 0
  • +

Replies To: Batch - rename to #ofWeek

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1304
  • View blog
  • Posts: 4,488
  • Joined: 19-February 09

Re: Batch - rename to #ofWeek

Posted 05 July 2013 - 06:31 PM

Hi, in the for there are three tokens %%d, %%e and %%f

@echo off

for /F "tokens=1-3 delims=/" %%d in ("%date%") do (
   echo %%d %%e %%f
   set ddmmyy=%%d.%%e.%%f
   set /A dd=%%d-0, mm=%%e-0, yy=%%f-0, yyM1=yy-1
)

echo %ddmmyy%
echo %dd%, %mm%, %yy%, %yyM1%




remove commas at end of these lines

set /A a=yy/100, b=a/4, c=2-a+b, e=36525*(yy+4716)/100, f=306*(mm+1)/10,

set /A a=yyM1/100, b=a/4, c=2-a+b, e=36525*(yyM1+4716)/100, f=306*14/10,  


Was This Post Helpful? 0
  • +
  • -

#3 ZickZak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-July 13

Re: Batch - rename to #ofWeek

Posted 06 July 2013 - 01:36 AM

Some guy fixed it for me yesterday, thanks anyway. The problem was in my local settings I guess, or I dunno....

@echo off
for /F "tokens=1-4 delims=. " %%d in ("%date%") do (
set ddmmyy=%%d %%e.%%f.%%g
set /A dd=1%%e-100, mm=1%%f-100, yy=%%g, yyM1=yy-1
)
if %mm% lss 3 set /A mm+=12, yy-=1
set /A a=yy/100, b=a/4, c=2-a+b, e=36525*(yy+4716)/100, f=306*(mm+1)/10, jdn=c+dd+e+f-1524
set /A a=yyM1/100, b=a/4, c=2-a+b, e=36525*(yyM1+4716)/100, f=306*14/10, days=jdn-(c+1+e+f-1524)+1
set /A week=(days)/7+1
rename "D:\2\1.txt" "%ddmmyy% %week%.week.txt"

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1