Subj : Re: .bats To : Paul Hayton From : Spiro Dotgeek Date : Sat Oct 18 2014 20:03:56 PH> I'm having a moment, can you help? :-) PH> I just want to set up a .bat file in my windows box to take a log file, PH> rename it with a date/timestamp and then move /copy it off to another PH> dir. I don't actually know anything about batch scripting on windows. I'm a unix guy through and through, and that whole script could be replaced with a one-liner in linux: mv $sourcefile $(date +"%Y-%m-%d_%H-%M-%S").txt :) I did start looking into that script, but I think windows uses variables differently on the command line and in scripts, and one uses %% and one uses % and I can't remember which is which. PH> for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set PH> "dt=%%a" If I run the wmic command from the CLI, it doesn't work if I include the ^ symbol. And I can't see why the delims are set to nothing (ie; "delims=" when there are no characters that act as delimiters in the output of the wmic command. So that just seems pointless. But I get different errors depending on which parts of the code I try to "fix." BAT files really are just batch files. That is, a batch of CLI commands. It's not a scripting language or script interpreter, and you're really hamstrung by it. My understanding is that windows powershell fixes this hole, but I've never used it myself. Another option open to you would be to install Cygwin, which gives you unix-like commands and scripting power from Windows. Although, if this is your only scripting requirement that might be overkill. :) Just found this on powershell renaming: http://stackoverflow.com/questions/14945253/powershell-file-rename-date-time and wow.. this piece of code: Get-ChildItem "$dlpath\*.pgp" | ForEach-Object { Move-Item $_.FullName "$BackupFolder$($_.BaseName -replace " ", "_" -replace '\.([^\.]+)$')-$(Get-Date -Format "MMddyyyy-HHmmss").pgp" } shows me Windows is waaaaaay too complex for me. :) Sorry, outta my league. --- Mystic BBS v1.10 A52 (Linux) * Origin: The Shadow Dominion BBS (3:772/300) .