Link to home
Start Free TrialLog in
Avatar of Satish B
Satish B

asked on

How to move files from subfolders in one folder

I have .ods files in branch wise folder, in branch folder there is Subfolder named Data in data folder there  are date wise folders in which file is exist.
i want to copy that file with .ods extension from current date folder to one single folder. e.g. i have 120 branches so i need to get each file from current date folder in One single folder.

example of files available subfoders:
C:\Users\Bandra\DATA\19\04\2017\Bandra.ods
C:\Users\Santacruz\DATA\19\04\2017\Santacruz.ods
C:\Users\Sion\DATA\19\04\2017\Sion.ods
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

What that has to do with SQL Server?
Avatar of Satish B
Satish B

ASKER

This was not related to SQL Server
Typically, I do as follows (assuming it is a one time requirement)

In DOS prompt (command prompt for some) and issue following query:

c:\Users>dir *.ods /S /b > odsfiles.txt

This will create the odsfiles.txt file in the folder. Open it with NotePad or NotePad++. Copy entire contents of the file.

Open MS-Excel and paste the contents in cell A1.

Paste the following formula in B1:

=SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1, "\", REPT("\", 100)), 100)), "\", "")

Paste following formula in in C1:

="copy """ & A1 & """ ""D:\Folder\" & B1 & """"

Copy the entire contents of C1 cell and paste them in command prompt. You files will be copied.

Needless to mention, change the target folder name.

DISCLAIMER: Please be very careful while playing  with data. Take safe copies if possible.
This was not related to SQL Server
Removed SQL Server topic and added Windows topics to call the right Experts.
Try to open a command prompt and run the following:
for /r "C:\Users" %a in (*.ods) do copy "%a" "C:\targetFolder"

Open in new window

Dear Vitor this will copy all files from others date folders also i want to copy the file from specific dated folder.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Vitor thanks !!! It works now was entering wrong path.  Thank a lot.......