Automating a task

Off-topic posts of interest to the "Everything" community.
Post Reply
kazzybash
Posts: 110
Joined: Mon Mar 02, 2020 9:55 pm

Automating a task

Post by kazzybash »

hi all,

got this archive of excels, neatly ordered. New excels come in regularly, offered in archives. I download those, unpack and then move the newly created folder with contents ('new set') to the archive ('old set'), by hand.

I would like to automate this. Thing is that the foldernames in 'new set' do not exactly match foldernames in 'old set' (say 60-80% of the foldername matches, 40-20% is different).

Any suggestions as to how (parts of) this task could be automated?

Kind regards, kazzy
therube
Posts: 4955
Joined: Thu Sep 03, 2009 6:48 pm

Re: Automating a task

Post by therube »

Not too clear on what you have, what you're getting, & what you want.

Anyhow, FASTI7.BAT:

Code: Select all

777 x %* -o*  %2 %3 %4


:: with %2 %3, you can do something like
:: 777 x *.zip  -o*  *.exe  *.chm
:: which would ONLY extract .exe & .chm
:: files from the .zip, rather then (by
:: default) ALL files...

:: like for with sysinternal files, you'd
:: want the .exe & .chm, but nothing else
777(.exe) is the command line version of 7-Zip (simply renamed to 777.exe - in my case).
And it basically says to take the filename(s) passed, & extract their contents into an individual (sub)directory (of the current directory) with said subdirectory named the same as the archive (or whatever the item may happen to be, so long as 7-zip can extract it).

So say you have:

C:/OUT/

And into C:/OUT/ you are getting excel*.zip files.

excel1.zip
excel2.zip
...
excel999.zip

> FASTI7.BAT excel1.zip
would extract the contents of excel1.zip into C:/OUT/excel1/

> FASTI7.BAT excel999.zip
would extract the contents of excel999.zip into C:/OUT/excel999/

> FASTI7.BAT e* (or FASTI7.BAT * if you're OK with something that broad)
would extract the contents of any file starting with E (or any file that 7-zip can unpack) into individual subdirectories in C:/OUT/, with those subdirectories named the same as the "archive" file


So with that, you have quickly & easily extracted all your files, into individual directories for each archive.
(Experiment, so you have a good feel for what is going on, because I believe, how you do things, you could run into a recursion issue, where you might unpack - everything, up to a point ;-).)


Now that part of the directory names, & between old & new, that I'm not following at all?
kazzybash
Posts: 110
Joined: Mon Mar 02, 2020 9:55 pm

Re: Automating a task

Post by kazzybash »

wow, thanks man!! I will go into this coming weekend and report back Nice! regards, Kazzy
kazzybash
Posts: 110
Joined: Mon Mar 02, 2020 9:55 pm

Re: Automating a task

Post by kazzybash »

hi therube, thanks a lot for your effort in answering my question. I am not certain whether we understand each other. Let me try to clarify my situation. Please have a look at the picture:
foldertree.jpg
foldertree.jpg (116.85 KiB) Viewed 4588 times
On the column on the left I have a few new folders with new files. The column next to that shows the existent foldertree in which those have to be merged. Third column shows what it would look like if I would do that automatically. Fourth column shows how I wished it would be (with the yellow folders being subfolders of already existing folders).

Would any such thing be possible to do automatically?

Regards, kazzy
therube
Posts: 4955
Joined: Thu Sep 03, 2009 6:48 pm

Re: Automating a task

Post by therube »

What I proposed would give you, 'New Foldertree After Merge'.

I suppose ? something similar could be done in a loop?
Where every directory name that contains an "extension" (so, "00 Excel 03.SAR"),
you could extract it to a parent directory, named the same, sans the "extension".

So something along the lines of (& pseudo-code):

Code: Select all

for %i in (*.*) do
777 x %i -o%ni\%i
done
(General idea, syntax not going to be correct. You certainly would want to test... & also make sure that "00 Excel 03.SAR" is treated differently from "00 Excel 03", where with the former, you want it to go into a subdirectory, but with the latter, not.

Likewise, don't even know if -o%ni\%i is going to be valid to 7-zip?)
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Automating a task

Post by NotNull »

So .. what aret hese zip-files called? (what pattern describes their names?) Are they all in the same folder? Are the "00 Excel*"foldernames in the zipfiles or based on the names of the zipfiles?

Please be as specific as possible as a wrong description leads to a wrong answer and all work has to be done multiple times.
(as the expression goes: "garbage in == garbage out")
kazzybash
Posts: 110
Joined: Mon Mar 02, 2020 9:55 pm

Re: Automating a task

Post by kazzybash »

hi, I tried but cannot get this to work, it clearly is beyond my capabilities :) . But I found a way to get closer to what I achieve by using this line of code the two of you came up with in another topic: regex:"^(.{5})" dupe:path;regmatch1 . I need to complete the task by hand, but this is already so much more in the direction that it saves me a load of work. So thanks a lot for that, it's great :!: . kazzy
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Automating a task

Post by NotNull »

If you answer the questions I asked, I will likely have a solution for you: a script that will extract the zipfile(s) to the right folder without further interaction.
If the information is personal or otherwise not meant for the public, you can send me a PM too.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Automating a task

Post by NotNull »

Not interested? Please say so (I need closure ..)
kazzybash
Posts: 110
Joined: Mon Mar 02, 2020 9:55 pm

Re: Automating a task

Post by kazzybash »

hi NotNull, sent you a PM. Thanks for your efforts, truly appreciated. regards, kazzy
Post Reply