Re: Rename nested folders
Re: Rename nested folders
- Subject: Re: Rename nested folders
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 23 May 2008 09:34:09 -0400
I sent this solution in bare shell form to Dan offlist after he sent a
screenshot confirming that the files had colons rather than slashes in
the ZIP file that Windows was unable to extract. Haven't heard back
yet on if his issue is resolved. Here's the same code I sent wrapped
in AppleScript:
set zipFile to choose file with prompt "Select ZIP file to fix"
do shell script ¬
"z=" & quoted form of POSIX path of zipFile & "; " & ¬
"t=/tmp/fixzip$$; " & ¬
"mkdir \"$t\" && " & ¬
"cd \"$t\" && " & ¬
"unzip -qq \"$z\" && " & ¬
"find . -name '*:*' -print | " & ¬
"while read f; do " & ¬
"mv \"$f\" \"$(echo \"$f\" | tr : -)\"; " & ¬
"done; " & ¬
"mv \"$z\" \"$z.orig\" && " & ¬
"zip -qr \"$z\" *; " & ¬
"cd - >/dev/null; " & ¬
"rm -rf \"$t\"; "
It changes the colons to hyphens and, by dint of using "zip *" instead
of "zip ." at the end, even removes the resource fork tree.
Obviously that's a ton of shell with a thin AS wrapper, and I am not
advocating it as the best solution, only the one that was easiest for
me to develop. At least most of the operations, if not all, could be
achieved with pure AS; the one I'm not sure about is the exclusion of
resource forks from the recreated archive. Of course, even if I'm
right about not being able to do that, a mixture would also work -
extract the archive and do the renaming with the Finder, then use do
shell "zip" to recreate it.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden