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\Band ra.ods
C:\Users\Santacruz\DATA\19 \04\2017\S antacruz.o ds
C:\Users\Sion\DATA\19\04\2 017\Sion.o ds
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
C:\Users\Santacruz\DATA\19
C:\Users\Sion\DATA\19\04\2
What that has to do with SQL Server?
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(SUB STITUTE(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.
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(SUB
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 ServerRemoved 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"
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Vitor thanks !!! It works now was entering wrong path. Thank a lot.......