{"id":3533,"date":"2022-02-05T23:30:29","date_gmt":"2022-02-05T15:30:29","guid":{"rendered":"http:\/\/euhat.com\/wp\/?p=3533"},"modified":"2023-07-01T08:25:58","modified_gmt":"2023-07-01T00:25:58","slug":"re-compress-all-mame-zip-roms-to-7z-format","status":"publish","type":"post","link":"http:\/\/euhat.com\/wp\/2022\/02\/05\/re-compress-all-mame-zip-roms-to-7z-format\/","title":{"rendered":"Re-compress all Mame zip roms to 7z format"},"content":{"rendered":"<style>\n.question { color:blue; }\n.verifying { color:red; }\n<\/style>\n<p>In advance, <\/p>\n<ul>\n<li>\ninstall 7-zip in \"d:\\cext\\Program Files\\7-Zip\".\n<\/li>\n<li>\ninstall git from <a href=\"https:\/\/git-scm.com\/download\/win\" rel=\"nofollow\">https:\/\/git-scm.com\/download\/win<\/a>\n<\/li>\n<\/ul>\n<p><b class=\"question\">trans_to_7z.sh<\/b><\/p>\n<pre lang=\"bash\" line=\"1\">\r\n#!\/bin\/bash\r\n\r\nPARENTDIR=$1\r\nTMPDIR=`pwd`\/tmp\r\n\r\nPATH=\"\/d\/cext\/Program Files\/7-Zip:$PATH\"\r\n\r\nISERR=\"no\"\r\n\r\nif [ \"x$1\" = x ] ; then\r\n\techo \"Please input dir to transform.\"\r\n\texit\r\nfi\r\n\r\nif [ -e \"$TMPDIR\" ] ; then\r\n\techo \"Please rmdir [$TMPDIR] first.\"\r\n\texit\r\nfi\r\n\r\nget_win_path()\r\n{\r\n\tlocal win_path=\"$1\"\r\n\twin_path=\"${win_path#\/}\"\r\n\twin_path=\"${win_path\/\/\\\/\/\\\\}\"\r\n\twin_path=\"${win_path\/\\\\\/\\:\\\\}\"\r\n\techo $win_path\r\n}\r\n\r\nformat_transform()\r\n{\r\n\tlocal file_7z=$1\r\n\tlocal file_zip=$2\r\n\tlocal tmp_dir=$TMPDIR\r\n\tmkdir \"$tmp_dir\"\r\n\r\n\t7z x ${file_7z} -o\"`get_win_path \\\"$tmp_dir\\\"`\"\r\n\t(\r\n\t\tcd \"$tmp_dir\"\r\n\t\tls\r\n\t\t\r\n\t\t7z a -mx9 \"`get_win_path \\\"${file_zip}\\\"`\" || ( echo \"Creating 7z file failed.\" && ISERR=\"yes\" )\r\n\t)\r\n\r\n\trm -Rf \"$tmp_dir\"\r\n}\r\n\r\ncd \"$PARENTDIR\"\r\n\r\nfor fn in `ls *.zip`; do\r\n\r\n\techo \"$fn\"\r\n\t\r\n\tformat_transform $fn \"`pwd`\/${fn%.zip}.7z\"\r\n\r\n\tif [ $ISERR = \"yes\" ]; then\r\n\t\texit\r\n\tfi\r\ndone\r\n\r\necho \"Transforming done.\"\r\n\r\n<\/pre>\n<p><b class=\"question\">How to use?<\/b><\/p>\n<p>Copy trans_to_7z.sh to Mame root folder which contains roms sub-directory, right click at blank place of this Mame root window in Explorer, select \"Git Bash Here\" which prompts bash console, input below and return,<\/p>\n<pre lang=\"bash\" line=\"1\">\r\n.\/trans_to_7z.sh roms\r\n<\/pre>\n<p>refer to:<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/wq242424\/p\/15564203.html\" rel=\"nofollow\">https:\/\/www.cnblogs.com\/wq242424\/p\/15564203.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In advance, install 7-zip in \"d:\\cext\\Program Files\\7-Zip\". install git from https:\/\/git-scm.com\/download\/win trans_to_7z.sh #!\/bin\/bash PARENTDIR=$1 TMPDIR=`pwd`\/tmp PATH=\"\/d\/cext\/Program Files\/7-Zip:$PATH\" ISERR=\"no\" if [ \"x$1\" = x ] ; then echo \"Please input dir to transform.\" exit fi if [ -e \"$TMPDIR\" ] ; then echo \"Please rmdir [$TMPDIR] first.\" exit fi get_win_path() { local win_path=\"$1\" win_path=\"${win_path#\/}\" win_path=\"${win_path\/\/\\\/\/\\\\}\" win_path=\"${win_path\/\\\\\/\\:\\\\}\" ... <a title=\"Re-compress all Mame zip roms to 7z format\" class=\"read-more\" href=\"http:\/\/euhat.com\/wp\/2022\/02\/05\/re-compress-all-mame-zip-roms-to-7z-format\/\" aria-label=\"More on Re-compress all Mame zip roms to 7z format\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[738,28,158,735,299,737,415,528,736],"_links":{"self":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/3533"}],"collection":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/comments?post=3533"}],"version-history":[{"count":10,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/3533\/revisions"}],"predecessor-version":[{"id":5312,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/posts\/3533\/revisions\/5312"}],"wp:attachment":[{"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/media?parent=3533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/categories?post=3533"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/euhat.com\/wp\/wp-json\/wp\/v2\/tags?post=3533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}