Move files from multiple folders to a single folder without extension - copy

i am a windows user and i need help with something
i have a folder and in it it has multiple folder.and in those multiple folders i have more folders and in those folder i have files without any extension like jpg,txt etc
here is a sample
D:\test\1\something1\1235486[file]
D:\test\1\something2\1235486[file]
D:\test\2\something1\1235486[file]
D:\test\2\something2\1235486[file]
so now i want to move all those random number files i.e 123456789[these files are without any extension] to D:\newtest
so i will have files like
D:\newtest\123456789
D:\newtest\123456789
D:\newtest\123456789
D:\newtest\123456789
etc. i could have easily done this with search option if it had a extension.but what can i do now?

Finally Found a solution for this problem
First make another folder where you want to transfer file
lets say i have a folder named ABC and i want to transfer its files to XYZ [only files not folders]
then open Command prompt [cmd]
and enter this
for /f "tokens=*" %a in ('dir /b /s /a-d "d:\abc"') do #copy "%a" "d:\xyz
Change the folder names and hit enter.it will transfer all the files in it

Related

Copy files in different subdirectories to another directory using a file list

so I have a list of about 26,000 files that I need Copied/moved to a different directory on a server. The different files in the list all have different sub-directory locations and names in the main source folder and the paths are specified in the filelist document.
The source filepath is on a network drive so (V:\RandomFolder\RandomSubdirectory)
The destination filepath would be on the local machine so (C:\RandomDestination)
I looked into seeing of robocopy could pull from the file list and move that way but I couldn't seem to find a way to make that work. Anyone got any ideas? I'd really appreciate any help.
Okay I figured it out, if anyone runs into this conundrum just follow like what is below( and edit to your liking and save it as a .bat
`#ECHO ON
SET FileList=C:\listoffilestomove.txt
SET Source=\\TopLevelOfNetworkOrFolderSourceDirectory\
SET Destination=C:\yourdestination
FOR /F "USEBACKQ TOKENS=*" %%F IN ("%FileList%") DO XCOPY /F /Y "%Source%\%%~F" "%Destination%\"
GOTO :EOF`

Windows script to merge all .html files in a directory and its subdirectories into a single .html file?

I have a Results directory, which has many subdirectories each containing a HTML file with a specific naming format, _ExeReport.html.
I want to write a Windows script which merges each of those files into one file.
For now, I tried running two commands :
dir /S *_ExeReport.html
This is listing all the files (with some extra information), and:
copy /b *.html final.html
This is merging all the files in current directory into one file.
But, I am not able to write a script which can combine and do everything I need.
Can someone help me with this? I am newbie to scripting languages.
Thanks to #T3RR0R for sharing the link. My final command :
FOR /F "tokens=*" %G IN ('dir /b /s *_ExeReport.html') DO TYPE "%G" >> MergedOutput.html

Copying files from similar multiple folders into each of their child folders

I would like to use a batch file to copy files in a folder to a backup folder (OLD) within, on a Windows server. And I want to do this for multiple folders.
So for example, I have multiple folders, named like this:
C:\A01
C:\A02
C:\A03
...
C:\A50
I will nickname them here as A##.
Each folder has hundreds of files.
Then each year before updating them, I copy those files into a backup folder called OLD, for each A##, so I have a backup of last year's files. Then I copy in new files into C:\A##, in another manual process, individually.
So there will be folders like:
C:\A01\OLD
C:\A02\OLD
C:\A03\OLD
...
C:\A50\OLD
When I do the copy, to the OLD folder, I keep the most recent version of each file. But then the files that I later manually copy in will overwrite in the C:\A## folder and be this year's files, while C:\A##\OLD will contain last year's files.
How can I script this so it will copy all the files for each C:\A## folder into their respective \OLD folder?
I assume I would use a variable for the path I want to copy from and to.
I could use Robocopy or Xcopy.
in a script file
#echo off
cd c:\
for /f "usebackq delims=:" %%a IN (`dir /AD /B ^| FINDSTR /I /R "A[0-9]*"`) DO (
#mkdir "%%a\OLD"
xcopy "%%a\*.*" "%%a\OLD\" /ECIFHRY /D
)
it copy only the updated files (/D) to the OLD subfolder.
if you want to mantain ACLs of the files, use /ECIFHRKOXY
I suggest you to test it in a test folder, that you can generate with this commands directly in the shell
#mkdir c:\test76
cd c:\test76
For /L %a IN (1,1,10) DO #mkdir A%a && echo "the quick brown fox jumps over the lazy dog">A%a\file.txt

Copy Files Created Today from Multiple Directories into a Single Folder

I'm trying to copy files from multiple subfolders into a single folder without re-creating the subfolders in the destination folder. I have a command that will do this, however, the problem that I have is this is something that I need to run daily as new files are created. So I don't want to re-copy the files from the previous day. I only need to copy files that are created on the current day. The command that I am using is:
for /f "tokens=*" %a in ('dir /b /s /a-d "e:\testfrom" ') do #copy "%a" "e:\testto"
This does copy everything that is in the testfrom folder and puts it into the testto folder.
How can I get this to copy files in the testfrom folder that are created on the current day?
Thanks!!

How to use Robocopy to copy a template folder structure to other folders?

I need to copy all the folders within one folder, to multiple other folders. The folder structure I want to copy from is here:
x:\Customer1\Site1\
I want to copy all the folders within Site1, to all the folders within the following directory:
X:\Customer1\
Obviously I don't want to copy the folders back into Site1 again, only every folder within Customer1, excluding Site1.
Site1 contains 19 folders. I would like to end up having those 19 folders within every folder in the Customer1 folder. Can someone please tell me how to achieve this?
I have been looking at the Robocopy MS page to learn about all the switches and options, but there doesn't seem to be anything to help me with this 'copying folder tree from one folder to multiple folders' that I need. Please give me any reference
Many thanks
Naz
As far as I know, this is only possible with xcopy's /t-switch which copies only the folder structure (note that if you also want empty folders to get copied you have to put the '/e' -switch as well)
To copy the structure in every subfolder a for-loop is the way to go:
set customer1="X:\Customer1"
set site1="Site1"
for /f %%d in ('dir %customer1% /b /ad') do (
if %%d NEQ %site1% xcopy %customer1%\%site1%\*.* %customer1%\%%d\*.* /t /e
)