Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Update

This is not working in my office pc. When i specificy the current month day as only 2. This is an data which it throws:-

How many Days this month: 2 The Month is (Blank) The Day is (Blank) The Year is (Blank) the Month is 2 days long C:\Documents and Settings\Desktop\hi\act\01--.xls C:\Documents and Settings\Desktop\hi\act\2--.xls C:\Documents and Settings\Desktop\hi\act\Master File.xls 1 file(s) copied. C:\Documents and Settings\Desktop\hi\act\01--.xls C:\Documents and Settings\Desktop\hi\act\06-Mar-2012.xls C:\Documents and Settings\Desktop\hi\act\2--.xls C:\Documents and Settings\Desktop\hi\act\Master File.xls 1 file(s) copied. C:\Documents and Settings\Desktop\hi\act\01--.xls C:\Documents and Settings\Desktop\hi\act\06-Mar-2012.xls C:\Documents and Settings\Desktop\hi\act\Master File.xls 1 file(s) copied

.

Original Question Below

There is an excel file for each day of the month. I need to create the Excel file for each day as per the date.

For example: There are 31 days in month of January, so the Excel files in each month's folder will be

01-01-12.xls
02-01-12.xls
03-01-12.xls
...
31-01-12.xls

Is it possible?


I tried this in a .bat file but I don't know how to construct the loop:

@For /F "tokens=1,2,3 delims=/" %%A in ('Date /t') do @( 
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%%A%%B%%C
)

@For %%a in ("*.xls") do copy %%a "import\%All%.xls"
share|improve this question
    
@Uday because your accounts aren't associated because you used two different email addresses, so I can't help associate your accounts. Either way, please keep using the account you used to edit this question –  Ivo Flipse Mar 6 '12 at 10:02
    
What do you mean "There is an excel file for each day of the month" What are the names currently, of your excel files, prior to running anything? –  barlop Mar 6 '12 at 15:30
    
I missed your last comment. Do you have enough rep to join the discussion now? –  barlop Mar 9 '12 at 1:10
    
@barlop now i can come for discussion as I have got 21 rep now. Please tell me when to come to chat. –  Uday Mar 9 '12 at 3:00
    
the chat is not live, so just go in now and type what you want and when i'm online i'll type what I want, then you come in later and type what you want etc. we don't have to be in there at the same time. –  barlop Mar 9 '12 at 9:04
add comment

2 Answers

Here is oneliner that will create today's file.

echo "" > { echo (gettime()+".xls") }

This is in biterscripting. Put this in a file x.txt file, then schedule this command to run every day thru task scheduler.

C:/biterscripting/biterscripting.exe x.txt
share|improve this answer
add comment
@echo off
set /P max=How many Days this month:  

for /f "tokens=1-3 delims=- " %%a in ('date /T') do @(
    set y=%%c
    set m=%%b
    set d=%%a

)

echo The Month is %m%
echo The Day is %d%
echo The Year is %y%
echo the Month is %max% days long
set d=01
Set /a max=%max%+1

:loop

SET adate=%d%-%m%-%y%

if not exist "C:\Documents and Settings\NGLD7640\Desktop\hi\act\%adate%.xls" copy "C:\Documents and Settings\NGLD7640\Desktop\hi\act\Master File.xls" "C:\Documents and Settings\NGLD7640\Desktop\hi\act\%adate%.xls"

set /a d=%d%+1

if not %d%==%Max% goto loop

Code adjusted and customized based on this discussion with @barlop.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.