Rename all the files in the folder including sub folders - file

I have a requirement to rename all files in a folder (including subfolders) by adding the last modified time in the original file name.
For Example... filename.txt and last modified time is 01/02/2018 7:10 then the new file should be renamed as filename_20180201_0710_V1.txt
The script should change all the files in the folder and subfolders.
Thanks
Regards,
Gowtham

Related

Loop through a directory in Talend

I have a Directory with many sub-directories in it including one named as OLD. This OLD folder could also be inside any of the sub directories and contains archived files.
Root Directory A
SUB-DIRECTORY A
file1.txt
file2.txt
SUB-DIRECTORY B
file1.txt
file2.txt
OLD
SUB-DIRECTORY C
file1.txt
file2.txt
SUB-DIRECTORY D
file1.txt
OLD
SUB-SUB-DIRECTORY E
file7.txt
OLD
I need to create a job in Talend which shall look for all OLD folders (in main and in sub directory both) and delete the files from that folder. I can use tFilelist to and mask the files to be deleted. But unable to figure out how to configure the job to look for OLD folder in all sub directories and delete those files also.
What you need to do is in the tFileList put your main folder choose check box include sub directories and in the FileList type drop down list choose Directories. Your file mask should be "OLD" or if it is anything more "OLD".
Iterate and use the parameter ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
to capture your sub directories. Now you can use this folder path in a tFileDelete Which can also delete folders
follow below approach..
Add tFileList and configure to Travers over all the directories.
now use if conndition connection from tFileList
Add tJava and connect with iterator connection
Add tFileDelete after tJava and connect with IF condition.
Add below condition inside if condition.
((String)globalMap.get("tFileList_2_CURRENT_FILEPATH")).contains("OLD")
Now you will get the all files from all the directories above code will give pass to the files which has the "OLD" in there file path.
I have not tested but you can try it.

Create batch file to copy mdb file to another folder and renaming it

I'm trying to create batch file to copy mdb file to another folder then renaming it and run a task scheduler everyday. so everytime the batch runs, the same mdb file will copy and rename. I don't care about the additional characters just copy and rename will do.
folder A (source folder)
test.mdb 06/21/2014
folder B (target folder)
test02.mdb 06/21/2014
test03.mdb 06/22/2014
thanks
copy "c:\folder a\test.mdb" "b:\folder b\test%random%.mdb"
The random number is 0 to 32,000. To do it by dates
Set NewDate=%date:/=%
copy "c:\folder a\test.mdb" "b:\folder b\test%newdate%.mdb"
This will copy and rename a file:
copy "folder A\test.mdb" "folder B\test02.mdb"

Need to copy and rename files in different folders

would anyone know how to write a batch file (or two) that would:
copy hundreds of "index.html" files that are in different folders and keep within the same folder (so needs to search within sub folders)
rename the copies (keep the originals as is) to "index.jpg"
could anyone help?
I used a bulk rename tool to rename all index.html files to index.jpg in a copy of the main folder, then used robocopy to copy everything over, including the file structure back to the original folder (leaving the index.html's alone)

How to exclude a specific file from being copied using xcopy

I'm new to Windows batch files, but I'm writing a .bat file that just copies a bunch of files from one place to another maintaining the file directory structure. Using xcopy this is simple but I need to exclude some files from being copied. You can use /exclude and create a text file full of strings that you want to be excluded, but this doesn't just exclude files with the exact names in the text file, it excludes all files whose filenames contain any of the strings in the text file.
What this means is, if I want to exclude any files named 123.txt and put this string in my exclusions text file, if there was a file called 1123.txt anywhere in the source folder or any of its subfolders that would also be excluded.
How can I exclude only files with a specific filename from being copied?
Evening Bill.
Can you add a slash before each file name? That should work
EG
instead of
123.txt
blah.txt
use
\123.txt
\blah.txt
Try creating a temporary folder, xcopying all of the files into that folder, deleting the ones you don't want, then xcopying those to the final destination. Finally, delete the temporary folder and its contents with rd xyzzy /q/s

Batch file. How do you target a few files by the first few characters of their filename

I want to move a few files from a folder to another folder, these few files have the same prefix in their filename, for example, myFile789789, myFile789798, myFile6787678, etc.
How do I target these files.
Just all files starting with that name?
MOVE myFile* "c:\somewhere"
move path1\myFile789789*.* path2
should do the trick.

Resources