Page 1 of 1

folder mover

Posted: 13 Dec 2017 07:06
by joe
hi,

I have 100's of folder with 1 file in each folder.

the folder name consists of 13 digits.

I need a script to move/copy only these folders with the content from source to destination.

any help

thanx in advance

Re: folder mover

Posted: 13 Dec 2017 07:55
by Squashman
A little more detail would help. Provide source and destination examples is normally very helpful.

Re: folder mover

Posted: 13 Dec 2017 07:58
by joe
the source E:\logfiles
the destination f:\fordeletion

Re: folder mover

Posted: 13 Dec 2017 08:21
by aGerman
move/copy only these folders
1) Which of either MOVE or COPY?
2) Folders where the name consists of 13 digits AND that contain only 1 file? Or only the first or only the latter? What exactly is the condition to select the folder?

Steffen

Re: folder mover

Posted: 13 Dec 2017 08:22
by Squashman
aGerman wrote:
13 Dec 2017 08:21
move/copy only these folders
1) Which of either MOVE or COPY?
2) Folders where the name consists of 13 digits AND that contain only 1 file? Or only the first or only the latter? What exactly is the condition to select the folder?

Steffen
I am not a Dentist but I play one on the forums.

I think only people in the USA will get that joke as it is used in a lot of commercials over the years.

Re: folder mover

Posted: 13 Dec 2017 08:44
by joe
the condition is move
to move all folders which contain 13 digit name to destination (all the folder contain a single file inside)

Re: folder mover

Posted: 13 Dec 2017 08:57
by aGerman
This should work if the destination folder already exists

Code: Select all

@echo off &setlocal
set "source=E:\logfiles"
set "destination=f:\fordeletion"

for /f "delims=" %%i in ('dir /ad /b "%source%"^|findstr /x "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
  move "%source%\%%~i" "%destination%\"
)
Steffen

PS @Squashman You could've left a Youtube link for extraterrestrials like me :lol:

Re: folder mover

Posted: 13 Dec 2017 09:11
by joe
ha ha ha

thanx steffen will update the results after running the script

that's so kind of you to have spent your time on this ..

joe

Re: folder mover

Posted: 13 Dec 2017 15:49
by SIMMS7400
Squashy -

I prefer the Holiday Inn one myself... LOL

Re: folder mover

Posted: 15 Dec 2017 06:54
by joe
yes this worked perfectly too

Thank you steffen :P