Jump to content

BOPBOP

Member
  • Posts

    5
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About BOPBOP

Profile Information

  • OS
    none specified

BOPBOP's Achievements

0

Reputation

  1. Yzowl, Thanks so much for your input. I’m a novice programmer (probably obvious) and use what tutorials are available to me as well as viewing what others have done in similar cases. This leads to somewhat piecemealed program code. Early on I had a little trouble getting the date to work in the format I needed. I was hung up trying to use %date% and saw someone else who had the same issue. A bit of code was supplied to them which I in turn edited and used for my purpose. So in regards to my pointless code :-) I’m not surprised I might have something in there I don’t really need. I’ll try out what you suggested because I much prefer “cleaner” code (also makes it easier to edit). I’ll have a look at the switches (/q and /f). START is now renamed, good point. Since my last post I’ve been adding other code parameters to this batch file and realized the echo back on was useless. I forgot what I was doing with that earlier. It’s gone. I’ll look into your last point about the date. I need to play with it to see what you mean because I do not want the day at the beginning, all I want is YYYYMMDD So, I just want to say I am always appreciative of anybody giving me pointers, especially when I am committing programming faux pas. It’s hard enough to figure out how I should edit my code without having extra lines that do nothing :-) thanks again for taking the time to look at the code and offer help.
  2. okay. Awesome, I combined your code into mine so I could keep my date format. Plus I like how you also showed me I was repeating code that I had already set in FileDate here it is. Again your help was much appreciated. @Echo Off :start cls set /p input= This program appends date to your filenames, do you want to continue (y/n)?: if /i "%input%" equ "y" goto :AppendDate if /i "%input%" equ "n" goto :ExitScreen echo Invalid choice & pause & goto start @Echo On :AppendDate echo Success! Dates Appended. See log file AppendlogYYYYMMDD.log for details. @For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @( Set FileDate=%date:~10%%date:~4,2%%date:~7,2%) if exist c:\Appendlog%Filedate%.log del /q /F c:\Appendlog%Filedate%.log @For %%a in (c:\new\*.txt) do ((echo copying "%%a" to "c:\import\%%~na_%FileDate%.txt" >>c:\Appendlog%Filedate%.log ) && (copy "%%a" "c:\import\%%~na_%FileDate%.txt" >>c:\Appendlog%Filedate%.log )) pause exit :ExitScreen echo Dates will NOT be appended to filenames pause exit
  3. opps. I know you mentioned the format change in the date but I did not look close enough to the code until just now. I forgot I avoided using %date% because it formatted the date to whatever the computer's setting were. And this batch file will be used on various computers I specifically need the date in the format of my original code or sometthing that gives me YYYYMMDD But what you supplied gives me something to go on. Thanks!
  4. Thanks Allen2! That's it! I'll play with the date structure later. I appreciate your help and quick response.
  5. ::This takes txt files located in a directory c:\new and while making a copy in the ::directory c:\import it appends the date to the file name in the format _YYYYMMDD ::A log file is created but it just says files copied ::I would like the log file to list the newly copied files that have the date appended. See code. Thanks!! @Echo Off :start cls set /p input= This program appends date to your filenames, do you want to continue (y/n)?: if /i "%input%" equ "y" goto :AppendDate if /i "%input%" equ "n" goto :ExitScreen echo Invalid choice & pause & goto start @Echo On :AppendDate echo Success! Dates Appended. See log file AppendlogYYYYMMDD.log for details. @For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @( Set FileDate=%date:~10%%date:~4,2%%date:~7,2% ) @For %%a in (c:\new\*.txt) do copy %%a "c:\import\%%~na_%FileDate%.*">>c:\Appendlog%date:~10%%date:~4,2%%date:~7,2%.log pause exit :ExitScreen echo Dates will NOT be appended to filenames pause exit
×
×
  • Create New...