Need to create a batch file [closed] - batch-file

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I need to rename folders across multiple directories. Directories look like:
101 Test
6982 Broad
5421 Scope
Within each of these directories, there are subfolders such as:
Correspondence
Billing and Invoices
Motions & Orders
and so forth....
I need to rename the the above subfolders in each of the above directories to be:
CORR
BILL
MOTS
How can I accomplish this?

Create the script not in the sub folder, but the folder above it.
Example:
ren Example Example1
In your case:
#echo off
ren Correspondence CORR
This should do the trick. Best of luck.

Related

How I can create a txt file with specific data using batch in a specific path? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to create 100 txt files starting from txt1 to txt100 with string data (i.e not to create an empty file) and it's doesn't matter if the data duplicate or not, I've just wanted to add some data in each file created in a specific path, so how can I do that?
We need a little bit more info such as what is going in the files and what name do you need for the files.
Give this a go as a start. It should create 100 files in C:\temp named as MyFile_1.txt through to MyFile_100.txt and each would contain the text Your Contents Here
#echo off
setlocal
set "txtpath=C:\temp\"
for /L %%a in (1,1,100) do >>%txtpath%MyFile_%%a.txt echo Your Contents Here

Batch file to delete text from txt file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a text file that contains gmail contacts, after each address there's the name of the email address owner example : John(at)gmail(dot)com:John and some other emails like this : John(at)gmail(dot)com;John
each address is in a new line, I want to delete all names and keep just the addresses, so I don't have to do it manually each time. how can I do this in batch script. I want to delete everything after ":" or ";" in every line. Thanks
It's a simple one-liner:
(FOR /f "delims=:;" %%a IN (filename1) DO ECHO %%a)>filename2
where filename* are your filenames and > should be replaced by >> to append to filename2 rather than creating filename2 anew.

Batch - Trying to read a text file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to make a batch file that will read a text file (Net.txt) to pull a datapath from it. Assign it to a variable then empty a file from a nearby location.
Net.txt looks like
SharedPath=C:\Program\2017\
SharedUNC=C:\Program\2017\
Then find the directory and delete files with a specific extension.
cd %variable%\OPTION\trash
DEL *.xxx
This works great locally when everything is on C: but I don't think batch/cmd supports UNC paths. Is there a better language to use?
To read a file line by line, use a for /f loop.
The following code assumes net.txt to be exactly as shown in your question and will delete the files in both the SharedPath and the SharedUNC (should they differ; if they are the same, del will spit an error for the second one (which you can suppress with 2>nul))
for /f "tokens=2 delims==" %%a in (net.txt) do del "%%aOPTION\trash\*.xxx"
If that is not what you want, please describe your problem in more detail.

How to rename files using Windows command prompt with keeping first 6 characters and replace all others by fixed text? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a batch of PDF files in a folder and I am trying to rename them.
Example:
File1_20170501_data.pdf
File2_20170401_statistics.pdf
Sale2_20170404_Misc.pdf
I only want to keep the first six characters of each file name (the five characters left to underscore and the underscore) and replace everything behind with sample data.
The final file names should be:
File1_sample data.pdf
File2_sample data.pdf
Sale2_sample data.pdf
Anyone can advice which command line to use for this file renaming task?
Given your provided information at the time of this answer, one simple command should do what you need:
Ren "C:\path to\a folder\?????_*.pdf" "?????_sample data.pdf"

Batch Rename Images - but keep original file, always [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Usually, I open cmd and use
ren oldname.jpg newname.jpg
and that works fine, but now I have an issue where I have to rename the same file into 50 or 100 different names.
How can I rename these, but keep the original file (so that I can continue saving it as a different name).
Thanks!
It seems like you need several copies from the same file. This should do it.
copy oldname.jpg newname.jpg

Resources