Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've a folder where every archive file has a correspondant image file with the same name. If ordered by file name then the structure of the folder is:

  • Folder
    • File1.zip
    • File1.jpg
    • File2.zip
    • File2.jpg
    • File3.zip (this file should be moved to a subfolder)
    • File4.zip
    • File4.jpg

If the archive file has not its image file then it should be moved to another folder.

One problem is that not all archive files are .zip, but also .rar or 7z and not all images are .jpg but also .jpeg or .png

It would be great if you could point me to the solution because I'm a web designer and .bat files are not really my domain :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
206 views
Welcome To Ask or Share your Answers For Others

1 Answer

While [SO] isn't a script writing service, I did find the task interessent.
Adapt the pathes in line 2+3 in the following batch to your environment.

@Echo off&SetLocal 
PushD "X:folder	ocheck"
Set "MoveToFolder=Y:movearc	o"
For /f "delims=" %%Z in ('Dir /B *.zip *.rar *.7z') Do (
  Set "FoundPic="
  For /f "delims=" %%P in (
    'Dir /B "%%~nZ*" ^| findstr /i ".jpg$ .jpeg$ .png$" '
  ) Do Set FoundPic=yes
  If not defined FoundPic echo Move "%%Z" "%MoveToFolder%"
)
PopD

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...