My folder structure is as follows :
and so on.
How do I copy the first file from each folder and rename them (maybe with the parent folder's name) so as to not ending up replacing them?
P.S :
I want to store them in a new folder with the same sub directories as source but with just one .wav file in each. And yes, in shell script or
Main_Folder/sub_folder_1/abc.wav
Main_Folder/sub_folder_1/def.wav
Main_Folder/sub_folder_2/abc.wav
Main_Folder/sub_folder_2/def.wav
Main_Folder/sub_folder_3/abc.wav
Main_Folder/sub_folder_3/def.wav
This folder structure repeats for all the sub_folders under the main_folder.
I want the output to look like :
New_Main_Folder/sub_folder_1/abc.wav
New_Main_Folder/sub_folder_2/abc.wav
New_Main_Folder/sub_folder_3/abc.wav
Related
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!
I need to do a bash script in order to copy all files which are in various subfolders and sub-subfolders of a main directory to a unique another folder while giving them a new name indicating their source.
Source paths and files are like:
MainDir/SubFolderX/SubSubFolderXY/fileZ.dat
MainDir/UnknowName../AnotherUnknowName../AnyFile.anyExtension
... Etc
Destination folder with renamed files would be:
NewDir/SubFolderX_SubSubFolderXY_fileZ.dat
NewDir/UnknowName.._AnotherUnknowName.._AnyFile.anyExtension
Etc
What I know is that there is only 2 levels but the names of the subfolders, the subsubfolders, the files, and their extensions could be anything.
I am renaming a resource files which first extension is 'hi-IN'. Now I need such a batch file which is change first extension to 'mr-IN' in a sub folders recursively. Some sub folders have no resource files.
file names are like this :
home.hi-IN.resx
home.en-GB.resx
index.hi-IN.resx
index.en-GB.resx
then output should be :
home.mr-IN.resx
home.en-GB.resx
index.mr-IN.resx
index.en-GB.resx
can we do this from batch script?
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?
I'd like to create a batch file under windows to move files with specific file names. I'd like to move all the files with txt extension and filename starting with "HH", and moving them only from root, sub directories excluded. And if a file with the same name is already exist in the destination directory I'd like to auto rename files instead of overwriting. Is it possible to do?
You can simply use:
move c:\HH*.txt destination_directory