move files from folders and sub into 1 folder

September 28, 2010 at 08:08:37
Specs: Windows 7
Part 1
I need any code that copy all files with extension (.bidd) from folders and sub folders into one main folder.

Part 2
After that divide those files into x number of diffrent folder

currently I'm using C++ code but it only do Part 2 and I do Part 1 manually.

Thank you for ur help in advance


See More: move files from folders and sub into 1 folder

Report •


#1
September 29, 2010 at 02:50:19
Hi abul7,

Part1:

@echo off
set DESTINATION=D:\BACKUP\
xcopy /S /Y C:\*.bidd %DESTINATION%
pause
exit

This will copy all .bidd files, in directories and in subdirectories to the given destination. (D:\BACKUP\)

The /S option: All directories and subdirectories.
The /Y option: Doesnt ask for confirmation for re-writing a file (if it exist in dest.)

I hope I did helped you,

Kind Regards,

MUs

start iexplore.exe http://www.computing.net/cgi-bin/my... & exit


Report •

#2
September 29, 2010 at 04:23:35
Thank you Mus,
I appreciate the effort, what if i want to cut the files or delete them from the original directory after copying them.

Report •

#3
September 29, 2010 at 06:52:46
Hi abul7,

I think there isnt a commando to cut directories\files, but there is a move command we can use. (its the same as cut..lol)

:SCRIPT-NOT-TESTED!

@echo off
set DESTINATION=D:\BACKUP\
xcopy /S /Y C:\*.bidd %DESTINATION%
pause
:LABEL
cls
echo Do you want 'Move' or 'Delete' the original directories\files?
echo.
echo 1. Move
echo 2. Delete
echo.
set /p "INPUT= > "
if %INPUT%==1 goto MOVE
if %INPUT%==2 goto DELETE
if not "%INPUT%" equ " a" goto ERROR

:ERROR
echo Please enter a valid option..
pause
goto LABEL

:MOVE
set MOVE-DESTINATION=D:\Original-Files\
move /Y C:\*.bidd %MOVE-DESTINATION%
pause
exit

:DELETE
set TO-DELETE-FILES=C:\*.bidd
del /Q %TO-DELETE-FILES%
pause
exit

Kind Regards,

MUs

"Don't put a question here." STFU :)


Report •

Related Solutions

#4
September 29, 2010 at 07:55:05
Again thank you for your quick reply
It works fine

Regards,
Abul7


Report •

#5
September 29, 2010 at 14:20:51
Hi abul7,

I'm glad I could help.

P.S. I did forgot to set the variable @ label :DELETE, but fixed now.

MUs,

"Don't put a question here." STFU :)


Report •

#6
October 1, 2010 at 06:02:58
Thanks guys I'm having similar issue with file system ...
anyway silly question:
what programming language run this code?

Junior Dev


Report •

#7
October 1, 2010 at 07:14:05
Hi Junior Dev,

It's just a batch file.

open notepad -> save as -> .bat extension.

MUs,

@"Don't put a question here" Why?


Report •

#8
October 1, 2010 at 13:30:26
OK Great,
but that will not work for me....
I'm talkning about 20000 files and the batch file is very slow for me..
Is there any other way to move files quickly...
I really care about the performance of the program so what is the better way to do that?

Report •

#9
October 1, 2010 at 20:41:50
Silly Question come again what variables should I change to run this batch file.

Report •

#10
October 2, 2010 at 01:55:47
Umm change these variable's:

::SET-DESTINATION
set DESTINATION=D:\BACKUP\

::SET-DIRECTORY-WHERE-TO-MOVE
set MOVE-DESTINATION=D:\Original-Files\

::SET-DIRECTORY-TO-BE-DELETED-FILES
set TO-DELETE-FILES=C:\*.bidd

MUs,

@"Don't put a question here" Why?


Report •

#11
October 2, 2010 at 04:20:17
OK it works fine except for the files in the sub folders inside the original folder.
they are not copied...!

Thanks,
Junior Dev


Report •

#12
October 2, 2010 at 08:31:57
Hmm wierd, it should be.

MUs,

Sup.


Report •

#13
October 2, 2010 at 11:30:32
Here is script i run:
you may check it your self if i mess sth.
_____________________

@echo off
set DESTINATION=C:\Users\Dev\Desktop\testing\Destination\*.bfs
xcopy /S /Y C:\*.bfs %DESTINATION%
pause
:LABEL
cls
echo Do you want 'Move' or 'Delete' the original directories\files?
echo.
echo 1. Move
echo 2. Delete
echo.
set /p "INPUT= > "
if %INPUT%==1 goto MOVE
if %INPUT%==2 goto DELETE
if not "%INPUT%" equ " a" goto ERROR

:ERROR
echo Please enter a valid option..
pause
goto LABEL

:MOVE
set MOVE-DESTINATION=C:\Users\Dev\Desktop\testing\Destination\
move /Y C:\Users\Dev\Desktop\testing\Location\*.bfs %MOVE-DESTINATION%
pause
exit

:DELETE
set TO-DELETE-FILES=C:\Users\Dev\Desktop\testing\Destination\*.bfs
del /Q %TO-DELETE-FILES%
pause
exit
________________

Thanks again for Relplying.
Regards,
Junior Dev


Report •

#14
October 2, 2010 at 12:05:34
I think this wont work:

LINE 2:
"set DESTINATION=C:\Users\Dev\Desktop\testing\Destination\*.bfs"

Destination is the place where the files should be copied to. And you have *.bfs extension.. So you want copy all .bidd files to .bfs files?
the destination should be without an given extension, just directories.
Like: set DESTINATION=C:\Users\Dev\Desktop\testing\Destination\

Replace: set DESTINATION=C:\Users\Dev\Desktop\testing\Destination\*.bfs
With: set DESTINATION=C:\Users\Dev\Desktop\testing\Destination\

MUs,

Sup.


Report •

#15
October 2, 2010 at 12:25:44
Dear MUs,
I have tried it works fine but it take only files from folder Location which is "C:\Users\Dev\Desktop\testing\Location" however, they are two level sub folders inside Location folder which content others files with .bidd extension are not moved.

Thank you

Regards,
Junior Dev


Report •

#16
October 2, 2010 at 12:34:43
Hmm,

I dont know, it should copy them too >:S

One thing; (my bad)

Replace: xcopy /S /Y C:\*.bfs %DESTINATION%
With: xcopy /E /Y C:\*.bfs %DESTINATION%

MUs,

Sup.


Report •

#17
October 2, 2010 at 12:54:00
Dude,
sorry but nothing changed it still can't access the sub folders and get thier files.


Report •

#18
October 3, 2010 at 13:37:09
Maybe the cannot copied folders\sub-folders\files are signed with "read only" property.

MUs,

Google is the answer.


Report •


Ask Question