I have around 500 JSON files sitting in their own directories that I need to re-name.
Every JSON file has the name, "list.json".
So what I need is a batch file operation for MacOS of some sort that will look in all the directories for files matching "list.json" and change the name to match name of the directory the file is sitting in. What kind of script do I need to do this?
Related
I try to backup files by zipping the files along with path and store it in external hard drive.
When I zip the files I insist that I include the complete path of the file so that when I unzip the files , I can make the files get stored in the specified path if it all , my hard disc crashes.
When I try to search for files with the following criteria in Windows Explorer
(System.FileName: *.txt OR .doc OR .xls OR .rtf ) AND datemodified:10-03-2021 .. 06-07-2022
Whatever the results I get I right click click 7 zip and click add to (some zip file name).7z
Now when I do this I am getting the error duplicate file name on disc
Of course I will be having same file name in different directories.
Since , I am saving the path along with the file name this duplicate error should not have come.
Please help me to zip files with the same name in different directories along with the path after I enter the following search condition in the Windows Explorer
(System.FileName: *.txt OR .doc OR .xls OR .rtf ) AND datemodified:10-03-2021 .. 06-07-2022
I am trying to move files of various extensions to a folder if the filename contains the folder name.
Simple example: I have several files such as Fox-1.doc, Fox-2.doc, etc. I have a folder named Fox. I'm trying to move the files into the folder Fox if folder name is contained in the filename.
I tried to modify the code in the following post but I was not successful.
Move files into existing folders containing part of the filename
Any pointers is appreciated.
If you are using code for doing this try getting the filename and filter from the .contains() method often found in Strings.
If you are using Linux command line I think this could work
mv *fox* destination_path/
For Powershell I found this thread that could help you:
powershell to move files based on part of file name
All you'd have to do is create the .ps1 with the modified script.
I have been tasked with stripping out around 50 thousand .INI files from a windows folder that has 58 thousand files in it the issue is that the files aren't in order and removing these manually would be very time consuming.
The files themselves use number Id's as their naming convention and I managed to get an Excel spreadsheet together with all the ID's I need to remove. My question is, can I put these ID's somewhere like a batch file and get it to remove these if so how?
Thanks in advance.
Here is the simplest script that will work:
cd "C:\directory\location\"
del "*.ini" /s
exit
The first line makes sure its in the directory that all the files are in, the second one deletes all the files in the specified folder and all of its subfolders (the subfolders can keep their .ini files if you remove the /s), and the third line quits the batch file. The third line is not necessary. The first line can be revoked if the batch file (.bat) is in the same folder as all of the .ini files.
I have a question copy files with batch at windows machine.
For example, I have a file named ja.html and duplicate the file to many files with certain file names following:
en.html
zh-ch.html,
ko.html,
id.html
in same directory.
Thanks in advance.
I would like to be able to copy all files from various folders and combine them into a single folder using a Windows batch file. That is fairly easy to do for me. But if the file already exists on the destination, I would like it to only override the file if it's newer.
copy c:\pics\ to d:\
Thanks.
You can use xcopy for more options if the source dirs are 2-3-5 (write separate xcopy lines for each). If the dirs are too many, you can use archiver like WinRar (or its command line rar.exe) with #list option where are stored the source dirs. In the batch file call RAR 2 times - first to pack all source files to one archive, then to unrar them in single folder (with E option, not X). Finally, you delete the .rar file. See the extra options to skip older files, omit prompts, etc.