Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows CMD Script 2

Status
Not open for further replies.

jmarkus

Technical User
Oct 15, 2002
124
CA
Sorry, I'm not sure if this is the right forum. I have a windows command script which adds "like-named" files (with an appended suffix) to a zip file.

Code:
for %%f in (*.zip) do "c:\program files\7-zip\7z.exe" a %%~nf.zip %%~nf_SUFFIX001.pdf

I now need to revise the script to accept similar names, but with a twist. Before I had:
filename_YYY.zip
and I added
filename_YYY_SUFFIX001.pdf
and everything was dandy!

Now I need to make it work with
filename_YYY.zip
and adding
filename.YYY_SUFFIX001.pdf

The underscore (_) has changed to a period (.)

Is there a way to revise my code to accept this new pdf filename?

Thanks,
Jeff
 
Code:
@echo off
setlocal
for %%J in (*.zip) do @call :func %%~nJ
goto :EOF

:func
set BAR=%1
set FOO=%BAR:_=.%
echo on
"D:\justin\portableapps\7-ZipPortable\App\7-Zip\7z.exe" a %BAR%.zip %FOO%_SUFFIX001.pdf
@echo off
goto :EOF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top