Jump to content

Recommended Posts

Posted (edited)

I've tried every combination and permutation of % and %% and A and a and ` ` and ' ' and " " and ... I can think of

I still get "syntax error"

I have x number of 7z archives of my thunderbird email account, backup1.7z, backup2.7z etc, in a /BACKUP dir

I want to set a variable to the oldest file name, so that the next time 7zip runs, it overwrites the oldest

batch is run from the /BACKUP dir

7za.exe command line version is in c:\windows

cls
DIR /B/O-D *.7z
rem successfully generates a list of 7zip archives with oldest file first

FOR /F %%A IN ('DIR /B/O-D *.7z') DO SET %OLDEST%=%%A
rem every permutation generates a "syntax error"!

7za a %OLDEST% "c:\windows\application data\thunderbird\*"
rem when %OLDEST% is set manually, 7zip generates the archive

can anyone see what I am doing wrong? help!

using w98se with soporifics/mgdx' autopatcher

Edited by Molecule

Posted (edited)

SET %OLDEST%=%%A 

Sets the VALUE OF the OLDEST variable to have the VALUE OF FOR loop variable A.

SET OLDEST=%%A 

Sets the OLDEST variable variable to have the VALUE OF FOR loop variable A.

Or, if you prefer, the actual variable is called "OLDEST" and "%OLDEST%" is expanded to the VALUE it was SET to.

Apart from this, the FOR /F needs a modified command.com (actually a CMD.EXE).

See here:

http://www.computerhope.com/forhlp.htm

http://reboot.pro/2392/

jaclaz

Edited by jaclaz

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...