Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
nickodemos
- Posts: 16
- Joined: 29 Jan 2013 08:17
#1
Post
by nickodemos » 29 Jan 2013 08:25
I have a script that works well except that it only does one file at a time. I was wanting to ask if someone could help make it so that it works by either dropping multiple files on top of the batch, do the directory it is in when activated, or both.
Code: Select all
if not [%~x1]==[.epub] goto :eof
START /w "" "%~dp0unzip.exe" %1 -d "%~dp0tmp"
CD %~dp0
for /r "%~dp0tmp\" %%a IN (*.opf) do sed -i -e "/<dc:date>NONE<\/dc:date>/d" -e "s,iso-8859-1,UTF-8," "%%a"
for /r "%~dp0tmp\" %%b IN (*.htm,*.html,*.opf,*.xhtml,*.xml) do sed -i -e "s,meta name=\"Adept.resource\" value=\"urn:uuid:[[:xdigit:]]\{8\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{12\}\"/,meta name=\"Inept.resource\" content=\"urn:uuid:00000000-0000-0000-0000-000000000000\"/," "%%b"
for /r "%~dp0tmp\" %%b IN (*.htm,*.html,*.opf,*.xhtml,*.xml) do sed -i -e "s,meta content=\"urn:uuid:[[:xdigit:]]\{8\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{12\}\" name=\"Adept.expected.resource\"/,meta content=\"urn:uuid:00000000-0000-0000-0000-000000000000\" name=\"Inept.expected.resource\"/," "%%b"
for /r "%~dp0tmp\" %%c IN (*.*) do touch -d "1980-01-01 0:00:00" "%%c"
CD %~dp0tmp
START /w "" attrib -a *.* /s
START /w "" "%~dp0zip.exe" -X0 "%~dp1%~n1-obfu.epub" mimetype
START /w "" "%~dp0zip.exe" -rDX9 "%~dp1%~n1-obfu.epub" * -x "*.DS_Store" -x "*.db" -x mimetype
CD %~dp0
RMDIR /s /q "%~dp0tmp"
-
Squashman
- Expert
- Posts: 4465
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 29 Jan 2013 08:31
Code: Select all
:BEGIN
if not [%~x1]==[.epub] goto :eof
START /w "" "%~dp0unzip.exe" %1 -d "%~dp0tmp"
CD %~dp0
for /r "%~dp0tmp\" %%a IN (*.opf) do sed -i -e "/<dc:date>NONE<\/dc:date>/d" -e "s,iso-8859-1,UTF-8," "%%a"
for /r "%~dp0tmp\" %%b IN (*.htm,*.html,*.opf,*.xhtml,*.xml) do sed -i -e "s,meta name=\"Adept.resource\" value=\"urn:uuid:[[:xdigit:]]\{8\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{12\}\"/,meta name=\"Inept.resource\" content=\"urn:uuid:00000000-0000-0000-0000-000000000000\"/," "%%b"
for /r "%~dp0tmp\" %%b IN (*.htm,*.html,*.opf,*.xhtml,*.xml) do sed -i -e "s,meta content=\"urn:uuid:[[:xdigit:]]\{8\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{12\}\" name=\"Adept.expected.resource\"/,meta content=\"urn:uuid:00000000-0000-0000-0000-000000000000\" name=\"Inept.expected.resource\"/," "%%b"
for /r "%~dp0tmp\" %%c IN (*.*) do touch -d "1980-01-01 0:00:00" "%%c"
CD %~dp0tmp
START /w "" attrib -a *.* /s
START /w "" "%~dp0zip.exe" -X0 "%~dp1%~n1-obfu.epub" mimetype
START /w "" "%~dp0zip.exe" -rDX9 "%~dp1%~n1-obfu.epub" * -x "*.DS_Store" -x "*.db" -x mimetype
CD %~dp0
RMDIR /s /q "%~dp0tmp"
SHIFT
IF NOT "%~1"=="" GOTO :BEGIN