folder mover

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joe
Posts: 23
Joined: 06 Sep 2017 07:56

folder mover

#1 Post by joe » 13 Dec 2017 07:06

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

Squashman
Expert
Posts: 3665
Joined: 23 Dec 2011 13:59

Re: folder mover

#2 Post by Squashman » 13 Dec 2017 07:55

A little more detail would help. Provide source and destination examples is normally very helpful.

joe
Posts: 23
Joined: 06 Sep 2017 07:56

Re: folder mover

#3 Post by joe » 13 Dec 2017 07:58

the source E:\logfiles
the destination f:\fordeletion

aGerman
Expert
Posts: 3066
Joined: 22 Jan 2010 18:01
Location: Germany

Re: folder mover

#4 Post by aGerman » 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

Squashman
Expert
Posts: 3665
Joined: 23 Dec 2011 13:59

Re: folder mover

#5 Post by Squashman » 13 Dec 2017 08:22

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.

joe
Posts: 23
Joined: 06 Sep 2017 07:56

Re: folder mover

#6 Post by joe » 13 Dec 2017 08:44

the condition is move
to move all folders which contain 13 digit name to destination (all the folder contain a single file inside)

aGerman
Expert
Posts: 3066
Joined: 22 Jan 2010 18:01
Location: Germany

Re: folder mover

#7 Post by aGerman » 13 Dec 2017 08:57

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:

joe
Posts: 23
Joined: 06 Sep 2017 07:56

Re: folder mover

#8 Post by joe » 13 Dec 2017 09:11

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

SIMMS7400
Posts: 357
Joined: 07 Jan 2016 07:47

Re: folder mover

#9 Post by SIMMS7400 » 13 Dec 2017 15:49

Squashy -

I prefer the Holiday Inn one myself... LOL

Post Reply