move folders containing a string - dos

I have a folder with several hundred subfolders.
I want to move all those where the folder name includes the string "moc"
I tried this:
move C:\Users\andre_000\Documents\THE UPLOAD\2015-06\2015-06
-08\WIP\Shared WIP\AU2_SP_OforC\*moc*.* C:\Users\andre_000\Documents\THE UPLOAD\
2015-06\2015-06-08\WIP\Shared WIP\AU2_SP_OforC
but I get an error that the commmand syntax is wrong

Wrap THE UPLOAD in quotes:
C:\Users\andre_000\Documents\"THE UPLOAD"\2015-06\2015-06
-08\WIP\Shared WIP\AU2_SP_OforC\*moc*.* C:\Users\andre_000\Documents\"THE UPLOAD"\
2015-06\2015-06-08\WIP\Shared WIP\AU2_SP_OforC

Related

Batch File to copy files from one subdirectory to another subdirectory that contains a "_" character

I've been struggling to get this script working and have been doing a lot of searching but can't seem to figure out how to do.
I have a specific directory and this directory contains two additional subdirectories, "User Data" and "a_bcdefg". The first subdirectory name is static but the 2nd subdirectory name is always random characters but always contains a single character at the start then an underscore "_". I am trying to copy all the files from "User Data" into "a_bcdefg" without having to specify the directory since the name is always different.
I've been trying various iterations of the following but can't get it to work:
xcopy /e /c "C:\temp\test\User Data\*.*" "C:\temp\test\*_*"

Replace files in multiple folders, whose name includes destination folder name

I have very little experience with the command line and I'm trying to do something very complicated (to me).
I have a directory with A LOT of subfolders and files in them. All file names contain the parent folder name, e.g.:
Folder1
data_Folder1.csv
other_file_Folder1.csv
Folder2
data_Folder2.csv
other_file_Folder2.csv
In another folder (all in one directory), I have a new version of all the data_FolderX.csv files and I need to replace them in the original folders. I cannot give them another name because of later analyses. Is there a way to replace the files in the original folders with the new version, in the command line?
I tried this Replacing a file into multiple folders/subdirectories but didn't work for me. Given that I have many .csv files in the derectories, I don't want to replace them all, so I don't think I should do it based on the file extension. I would also like to note that the name "FolderX" contains several other _, so in principal, I want to replace the .csv file starting with data in the FolderX.
Can anyone help?
Thanks in advance!

Rename multiple files with batch windows

I need to rename a group of .pdf files
In the \Source folder I have the files:
bbbbbbbbb-56.pdf
vduysdvss-60.pdf
sdvbdsbvv-80.pdf
I have to rename them in the \Destination folder like this:
11111111-bbbbbbbbb-ggg-hhh-56-dddd.pdf
11111111-vduysdvss-ggg-hhh-60-dddd.pdf
11111111-sdvbdsbvv-ggg-hhh-80-dddd.pdf
so I need to insert some fixed parts:
before the name
in the middle of the name
at the end of the name.
Using the command:
cd \Source
copy "\Source" "\Destination"
cd \Destination
ren *.pdf 11111111-?????????-ggg-hhh???-dddd.*
the result is:
11111111--56-ggg-hhh-dddd.pdf
the bbbbbbbbb string disappears
can you help me?
Thanks
By using the following command Copy the files from Source to Destination :
copy "/Source_folder" "/Destination_folder"
Go in /Destination folder
cd "/Destination_folder"
And then ren the file names by the following command :
ren *.pdf ???-new_filename_part.*
(The question mark (?) is also a wildcard, but it represents a character of the original file name. So, in the syntax, we're using three question marks, which means that the output file name will include the first three characters of the original file (which works as a unique identifier to avoid duplication)
(According to your logic you can change the new filenames by using some RegExpressions or some variables)

I'm looking for a script that will rename files and place them in a new folder

Essentially what I am looking to create is a script that will rename files in a folder, create a new folder with a specific name and place the renamed file in that new folder.
So, for instance, let's say that I had 2 files called:
test-spa.txt
test-ger.txt
I would then want to create 2 folders called spa and ger, respectively, place the appropriate file into each folder then rename the file by removing the language component; the resulting files in each folder would be test.txt.
Thanks,
Jaime
So here is the simple solution I came up with to create folders and place specific files in them. So long as I have the bat file in the same folder it works great:
#echo off
md spa ger
move file.txt EN\file.txt
move file-spa.txt spa\file.txt
move file-ger.txt ger\file.txt
I'm wondering if there is something missing that may cause an issue, such as specifying that this should only work in the current directory?

Rename folder by replacing sub-string using bat

Found this- How to rename file by replacing substring using batch in Windows it does the exact thing I am looking for.but, I want this for a FOLDER,not a file. I am tired to manage it for a Folder. Please do help. I want to make a search in the current folder(%CD) and replace all the folder names containing "MyImage" sub-string with "HerImage" substring.

Resources