The objective of this script is to create .cbz files without subdirectories because some utilities have problems with them mainly when there very long and generate errors or bad results.
Steps:
1- Start with a compressed file (.cbz, but we can also begin with .zip, .cbr, .rar)
2- Uncompressed it
3- Clean flatten structure directory
4- Delete original file
5- Generate a new compressed file with same name as the deleted one but with .zip (default)
6- Rename the .zip to .cbz to get the same filename.ext as we start
For the flatten operation I am using suction.exe which I found easy.
I also tried with DirFlatten.exe but I haven't been able to make it run. I also comment the operation in order someone can correct or see what am I doing wrong.
Improvements:
I have found when Main directory, filename, subdirectory and compressed names are VERY LONG suction.exe doesnt process these files. I don't know exactly the numbers but I have a problem with a file with these figures:
In my case, the path for the file I am having troubles is 258 char long in total
Main directory : 9 chars
Filename : 105 chars
Subdirectory: 98 chars
Image : 41 chars
TOTAL: 253 + \\\
Any suggestion to automate a reduction on the subdirectory or workaround?
I could rename directly to Sub1 (the name is not relevant because the info is on the Filename).
Can't really test right now, but the problem might come from the fact you delete the original file on step 4, hence loosing selection. Then when you reach step 6, {file} is empty since there are no more selected file.
You can try to store the value of the {file} before deleting it (@set as you did in the other post) and use that variable name in the final step.
EDIT : it seems you already have it in {extract_dir}
EDIT2 : As for suction, I don't know what it does, but if the goal in the end is to reduce folder depth, it's probably doable with Opus. If it has to handle "complicated" things (regroup in top folder files scattered in multiple sub-dirs), it will probably require scripting (JS or VB) and a bit of logic to decide what to do on duplicate names if it has to be automagic without user intervention ...
Thanks @PassThePeas . I dind't knew I loose a variable if the file associated is deleted.
Then I modified the script using loaded variables instead of {file} option.
test - Copy.cbz
test - Copy.cbz
test - Copy.zip
copy EXTRACT=sub HERE UNATTENDED=yes
c:\USBTools\Utilities\suction.exe "E:\COMICS\TEST\test - Copy"
Delete FILE="test - Copy.cbz" NORECYCLE QUIET
Copy ARCHIVE=single HERE FILE="E:\COMICS\TEST\test - Copy"
test - Copy.cbz
test - Copy.zip
Rename PATTERN "test - Copy.zip" TO "test - Copy.cbz"
Efectively, the output {file} doesn't show anything after deleting the file.
But the command rename seams to be correct (as before) but doesn' t rename anything.
crazy
Thanks @lxp for clarification. As said I couldn't test, and since the variable is not a user set one but the {file} variable which is supposed to represent the selected file, I thought it could be re-evaluated at that moment.
Using 7z.exe and as the majority of files I have to process has ONLY one subdirectory and no risk then to overlap if in uncompress everything without tree hierarchy.
Then for my basic needs I can reduce my script to two 7z commands
@nofilenamequoting
@sync:
@runmode hide:
@set file_init={file}
@set file_cbz={file|ext=cbz}
@set file_zip={file|ext=zip}
@set extract_dir={sourcepath}{file|noext}
// extract flat
C:\USBTools\Utilities\7z.exe e -o"{$extract_dir}" "{sourcepath}\{file}"
Delete "{sourcepath}\{file}"
// compress only files directly to .cbz file
C:\USBTools\Utilities\7z.exe a -tzip "{sourcepath}\{$file_cbz}" "{$extract_dir}\*.*"
Delete "{$extract_dir}"
With this I avoid the rename problem and the path length problem.
Anyway, I would like to understand why the rename PATTERN command doesn't work in the previous script (where I don't use 7z.exe to avoid the problem)
Very strange. I have copied the same script (commented suction)
and it is till not working. Here screen capture where you have the log and the directory where the .zip file is not converted to .cbz
very strange for me. As I explain before if I put the rename command in a single button it works. Then the disfunction is related with something happening before.
I thought i could be the file deletion. but adapting the variables to avoid it, doesn't solve the problem.
But now @PassThePeas say he run it without problem
I solved my need with another tool. But after all the time I have spend on this bloody command I would like to understand something.
Maybe it's related to the new archive being selected or not.
I tried to add Select *.zip DESELECT just before calling the step rename : it's not working anymore.
I tried to see if I could find any related setting that could be different between our two configurations, but the ones I found had no effect on the original script (without the DESELECT). I tried : File Operations / Copy / Select automatically new files copied/moved File Operations / Options / Deselect files used in a function
(sorry if it's not the exact name of the options, I'm trying to guess the english setting from my french one ).
Anybody would have an idea of a setting that would cause the zip archive not to be selected ?
You can use Rename FROM *.zip ... to make it act on all .zip files, without having to select them (which may not always be reliable if the file you're selecting was only just created; the lister might not have seen the new file yet). Most commands let you specify a path or wildcard to work on instead of the selection.
New problem to improve the scritps.
I see it works fine if I run only with one file.
I tried to select more than one file, then it doesn't work ok.
It run each command on all selected entry before beginning the next command/line.
Is there an option to make the scritp execute completly on the first file selected before running the script with the second file and so on?