Search for two or more 'patterns' and move files according to results
1 Attachment(s)
Hi
I'm lost with searching for 2 and then more 'patterns' within a file with a large number of filenames and according model names, then I want to rename and move the files to appropriate 'found' result (the source file attached). In short, searching for the name in line: Code:
D:\temp\OfflineExplorerPortable\Download\unicommerce.si\produkti\produkti\produkti_stihl\motorne_zage\lahke_motorne_zage\30\ms_5F250_c_be\default.htm and then I would like to rename it "30_big-b4d46b171375e7f3.jpg" -> "MS 250 C BE.jpg" and move it to the folder "ms_5F250_c_be" (which is found in 1.st line near end: ...orne_zage\30\ms_5F250_c_be\default.htm ). There is also the smaller picture "30_big-2443fdbb986dfef6.jpg" in the second like line which can be named "MS 250 C BE(1).jpg" and moved These are CMS uploaded files and named randomly so now the customer wants it sorted (updated and deleted unnecessary). Since I'm trying to do this with some kind of grep/sed... search for 2 days I'm lost and I have no script made yet, thus I'm asking kindly someone (if it can be done) for the complete search code, which I could use. I may have not provided exactly what I need to do, but I'm soooo messed up right now doing this manually, I could not appreciate more if this can do some script instead of me. Regards |
This may help get you started, obviously the syntax is wrong with the mixing of / and \.
Code:
#!/bin/bash Code:
cp 101_big-7903fadb4cddcfde.jpg D:\temp\OfflineExplorerPortable\Download\unicommerce.si\produkti\produkti\produkti_stihl\kombi_motorji\101\km_130_r\KM_130_R.jpg |
i create a file test.awk
Code:
/default.htm/ { h=$(NF-1); print "H="h } Code:
gawk -F "\\" -f test.awk file.txt Quote:
|
That is so great, thank you.
I've come only about 30% manually through, with this should be done in no time :cool: |
All times are GMT -5. The time now is 06:48 AM. |