Create a batch file to create multiple folders within many folders - batch-file

I am trying to create a batch file which will create folders within all sub-folders of a given folder. So for example if it ran in the directory C:\Example, it would create a folder a, b, and c under each of the 20 folders regardless of their name.
It would be much easier to do this automatically rather than copy the .bat file to every individual folder to create the 5 same folders every time with just md.
So far everything I have created has been a disaster, so I'm hoping someone can help me out with this.

for /d %%x in (*) do mkdir "%%x\a" "%%x\b" "%%x\c"

Related

Window Batch file to keep some specific folders and delete the rest

I have 100+ folders, and I want to run a batch file to keep certain folders like 10 folders with different names based on my list. Example I have folders like
1FL-12
1FL-44
1FL-86
2FL-95
2FL-73
2FL-25
3FL-52
4FL-53
4FL-35
5FL-85
I am trying to keep only the folder 2FL-95, 2FL-73 and 2FL-25 and delete the rest. Before I tried using rmdir /S /Q "C:\pathtodirectory" to delete the unwanted ones but its not that convenient when there are just too many folders to delete.
Is there any simpler way to keep only the folders and delete the rest?

How to rename PDFtk-server files with timestamp?

I am using PDFtk-server to merge 2 PDF files. This creates a new PDF with name Test_.
Now, what I am looking for is a batch files that renames the Test_ files to Test_datestamp and then move them into another folder and delete the files.
It is working if only one file is present.
pdftk C:\test\*.pdf C:\test\file-to-add\file.pdf cat output C:\test\output\Test_.pdf
ren "C:\test\output\*pdf" "Test_ - %date:/=.% %time::=-%.pdf"
del C:\test\*.pdf
Then comes to copy part to other folders.
If having multiple files, the first one gets renamed but other not, because it is trying to set the same timestamp, so I need some kind of delay between renaming.

Bat file to compare files within folder A against folder B

Please can someone help with the below
I have two folders:
C:\FolderA
C:\FolderB
Folder A contains a bunch of files like an archive
Folder B contains the same bunch of files with the same name, however some data within the files may be different.
I want to write a .bat file which uses the diff command to compare all the files from folder A to the files in folder B with the corresponding name (e.g. update0001 against update 0001) and outputs the difference in "C:\Folder C" with each file difference in a separate text output. (e.g one file is called “Error update0001” and another “Error Update0005”
This is a simple way to check the files in two folders and give results.
fc /b "c:\folder a\*.*" "c:\folder b\*.*" >"c:\folder c\results.txt"

Hey, i need help in batch to make it copy everything in 1 folder to another folder

im working on a script that have few folders and i don't really understand how to make an config for this but i don't need it.
i have setup a script config inside
Set cfg=cfg2
Set txt=txt2
Set rar=rar2
cfg2, txt2, rar2 are in a diffrent directory
the files in cfg are cfg files but theres alot of them.
this also goes for txt & rar too.
i want a copy script that copies all cfg files (and only cfg files) into the cfg2 file that are in another directory.
and then this goes again for the txt & rar files.
I also know the code for move but i really want to copy it
cause on move you just do
move "txt/*.txt" %txt% and thats kinda what i want to do but that aint working
Have a look at robocopy from microsoft.
Something like the below should work;
robocopy /s \path\cfg \path\cfg2 *.cfg

.bat file to rename and move files with prompt

I am completely new to this, but I am trying to create a .bat file that will allow me to rename a pair of files within a designated folder and move them into a subfolder. The part I am having trouble with is that I am wanting a prompt to come up to identify/select the files to be renamed and moved.
Example file names are:
A1234, A1235, A1236, B1234, B1235, B1236, etc.
Is there a way to bring up a prompt that allows the user to type the shared name (ex 1234)of the files and rename and move both files to the designated subfolder?
Any and all help would be appreciated!
Suggested approach
for part of problem
part I am having trouble with is that I am wanting a prompt to come
up to identify/select the files to be renamed and moved. Is there a
way to bring up a prompt that allows the user to type the shared name
(ex 1234)of the files and rename and move both files to the designated
subfolder?
Do a search operation using wildcard, like "?1234" for the case highlighted above ( should be made generalized for all acceptable and expected patterns "*1234*" is the generic most )
Now do a RENAME inside a For loop on the results obtained by search.
As you suggest you are a newbie with Batch, following tutorials will help you build your file. Look for elements like Variables, For Loop
Batch Tutorial
Here you go
#echo off
set /p file=Please type shared name:
for %%a in (C:\Folder\?%file%.*) do (
move "%%a" subdir
ren "subdir\%%a" newname.*
)

Resources