I have a directory with 45 sub directories in it, I want to change all the .html file in the sub dirs that have specific name to another name but keep the .html extension.
How to I do that in terminal please in opensuse?
maybe with 'rename" or with 'find' command ?
thanks
Related
I want a script that is able to read the content of a text file which contains folder names and moves the folders from their directory to a specific folder. Here is my script:
#!/bin/bash
for i in $(cat /folder/collected/folders.txt)
do
mv /fromfilelocation/$i /folder/Collected/
done
This script is partly working as it copies only the last folder in the text file, as for the other folders it gives the error "not possible: data or directory not found" But the folder is there and according to the error the folder directory is correctly displayed.
The names do not have special characters or white spaces and if either way full directory or only folder name in the text file it is the same error.
The error that is displayed is cannot find file or directory but it display the correct directory to the folder with a '$'\r'. example /fromfilelocation/foldername'$'\r.
This is error due to line feed characters.. do dos2unix on the file with directory names then run the script again. there is nothing wrong with script
I'm very new to Linux. Does anyone help me to explain what does a "file-of-file-names (fofn)" mean and how can I create fofn with the full path of each file?
As the name suggests the FOFN file contains an absolute path to specific set of files eg. files within a directory etc.
I believe there is a myriad of ways on how to create this kind of file. So, for example, to create FOFN file on the entire /etc directory one may execute:
# find /etc/ -type f > my_new_FOFN.txt
This will create a file called my_new_FOFN.txt containing a full-path a.k.a absolute path to each file within /etc/ directory recursively.
Recently I downloaded some files from a website, but their names contain strange unicode characters, which my console doesn't show them properly. Now I want to rename these files to be able to use these files, but I get the following error:
mv: cannot stat`FILENAME': No such file or directory
But I am sure that these files exist.
I wonder how I can rename these files, properly.
Any ideas?
Using globbing characters (like ? or *): mv *some-typeable-and-unique-substring* ...
Using the tab-completion of your favourite shell: your start typing mv, then the beginning of the filename, then you press TAB, and then you can enter the second parameter.
If there are other files in that directory, you might have to move them to another directory to be able to use the tab-completion or the wildcards.
I have a directory Dir in which I have about 30 sub-directories. From these 30 sub-dirs there are about 20 with name dir_date and the other 10 with some random names. I want to move all the directories that contain dir in their names to another directory which could be created under Dir using the command line. I am using CentOS 5.7
In a terminal, you can simply do
mv *dir* /example/location
where dir is a pattern that matches anything containing "dir". Fix the pattern to match your needs.
This will move all files containing "dir" in the directory you are in (in terminal, type pwd to check your current directory).
Ok, your directory name is "Dir"
Now Dir has 30 sub directories of which 20 starts with name "dir".
Lets say the other directory you want to create in Dir where you want store the files is "abc"
Thus, the following command:
mkdir Dir/abc
mv Dir/dir* Dir/abc
thats all ;)
lets say I have (linux/unix)
/directory/1/file.wmv
/directory/2/file.wmv
/directory/3/file.wmv
I want to copy these .wmv files into a single directory /example/ with files named after directory names they were in like so 1.wmv, 2.wmv, 3.wmv,
for i in {1..10}
do
cp /directory/$i/file.wmv /example/$i.wmv
done