Questions tagged [filenames]
File name is a name used to identify a file uniquely on given file system.
1,074
questions
2
votes
6answers
68 views
Get list of folders that are after certain number
I have a folder which subfolder naming convention is like yyyymm for e.g. 200801, 200803 etc. I want to list down folder after 201412 via command line means to upload to S3. Is there a way to do it?
2
votes
1answer
1k views
Find fails if filename contains brackets
I'm trying to use find inside a loop to create a variable that contains a file matching the filename + desired string
Example:
file1.en.srt
file1.mkv
file1.pt.srt
This is the relevant part of the ...
2
votes
1answer
68 views
How to differentiate an executable sh file, and a source sh file?
I have sh files that are executable, and others that are only meant to be sourced by executable ones.
On the executable ones I use no extension at all, and have the first line as #! /bin/sh.
On the ...
1
vote
2answers
3k views
how to remove all characters after and including “?” in filename?
I have a large amount of files that were downloaded and ended up having what looks like authentication parameters added to the filename which I would like to remove. Examples:
file1.doc?...
2
votes
2answers
73 views
Print Folders Missing .txt Filetype
I have 150 directories in a parent directory. Some of them have .txt files, others do not. I would like to print which folders do NOT have a .txt file. How can I achieve this?
4
votes
1answer
1k views
Dot in front of file [duplicate]
If there is a file and the filename starts with a dot in front of it. Does that mean that you created the file and you are hiding stuff in it or can the files get created on their own without you ...
2
votes
4answers
3k views
How to shuffle file names randomly in a directory
Say i have a directory of filenames:
file_010.ext
file_011.ext
...
file_99.ext
What's the simplest way to take each file and randomly rename it to any other name in the directory, without there ...
-1
votes
1answer
6k views
Filename with dot in front [duplicate]
If there is a file and the filename starts with a dot, does that mean you created the file and you are hiding stuff in it, or can the files get created on their own without you creating the filename?
-1
votes
2answers
66 views
How to batch rename files in folder [closed]
I have a zip file where each file is named the following
original.jpg.1.png
original.jpg.2.png
The files are actually jpegs
How do I go about renaming them to the following?
original1.jpg
original2....
1
vote
0answers
687 views
Sort directories before files and underscore first with ls
When using 'ls' i want to sort directories first and then all files AND sort directories/files with underscore first. Here is an example:
_folder2
folder2
_file2
file
I can sort directories first ...
1
vote
2answers
1k views
How to mass rename files with regular expressions [closed]
I have a bunch of folders in a directory with files in them. Most of the filenames have region codes (retropie), and the scrubber will not match roms with single letter region codes (u,j,e,etc.). I ...
1
vote
2answers
75 views
How to recursively move one file type but only when another file type is also present?
In my directory tree, some subfolders contain both *.flac and *.mp3 files, but other subfolders contain only *.mp3 files. I'd like to move all of the *.mp3 files to another destination (a different ...
3
votes
0answers
65 views
I can see but cannot delete a file [closed]
I am running Linux Mint.I tried to copy a file with the file manager. It looked like it hung.
I can see the file in the directory with ls -l:
-rwxr-xr-x 1 mike domain^users 20 Mar 1 08:57 'output (...
0
votes
2answers
938 views
Why does Linux allow a symbolic link to itself?
Because of a typo I found out that this is allowed: ln -s useless useless.
Then, as expected ls useless/* triggers this error message:
ls: cannot access 'useless/*': Too many levels of symbolic ...
7
votes
2answers
1k views
What is wrong with my use of “find -print0”? [closed]
I'm confused by this experiment (in Bash):
$ mkdir 'foo\n'
$ find . -print0 | od -c
0000000 . \0 . / f o o \ n \0
0000012
As you can see, "find" is correctly delimiting the output ...
1
vote
2answers
59 views
Finding a rogue script changing filenames?
I've got a server that is used as an SFTP endpoint and a script living somewhere else that periodically uploads to the server.
At a particular time every day all the files in the upload folder get ...
2
votes
0answers
62 views
Given a pathname and a symlink to a directory in the pathname, is there a command which can return an equivalent pathname making use of the symlink?
Sometimes I have a long pathname, and want to shorten it by some precreated symlink to a directory in the pathname. Specifically, given a pathname /path/to/file, and a symbolic link /symlink to a ...
0
votes
0answers
221 views
IFS variable and filenames with spaces and newlines
(Using Bash 4.4 and 5.0)
I am dealing with the issue of filenames that contain spaces, newlines and backslashes. I often read the suggestion to use code like this:
oldIFS=$IFS
IFS=
while read -rd ...
-1
votes
1answer
44 views
Grab last youtube video index and re-download .description
after I had download youtube videos with youtube-dl -cit -f 140 ' , I forget to download the .description as well... so I have bunch of files without description, I want to redownload the description ...
1
vote
1answer
41 views
Can't remove file from terminal folder
I would like to remove the .xlsx file below in terminal folder. When I right click and do delete, it gives error: no such file. When I do 'ls' in command line it is not listed either. I refresh the ...
1
vote
1answer
270 views
How to use the ls command to show all files except those ending in a specific string
I have a directory with files of all kinds and I wanted to use the ls command to list all of them, except those with a name that ends in .config, but I do not get how to do it.
7
votes
1answer
2k views
Why does scp's strict filename checking reject quoted last component but not others?
When I try to scp a file with a slash in its path, the path is quoted for the local host, and the last path component is additionally quoted for the remote host, like scp host:"a/b/'c'" ., it fails ...
0
votes
0answers
36 views
Add file number to beginning of each file in directory [duplicate]
If I have a directory, how do I add the number of the file to beginning of the filename? For example, the directory would look something like this:
file.txt
another_file.txt
And the expected output ...
0
votes
1answer
51 views
What distro allows you to create a folder and a file with the same exact name?
I am trying to figure out which distro this script (scene_splitter.sh) was built for. Everytime I try to use it I get the following error.
x@x-pc:/media/x/WD_2TB_HDD/test$ ./scene_splitter.sh 001.mp4
...
0
votes
2answers
782 views
How to list all filenames in the system [closed]
I want to perform checks on all files in the system. For that I need the full paths of all files in the system. My initial idea was to do something like this:
for file in $(sudo find / ); do
if [ -...
0
votes
2answers
74 views
How to save a web resource, applying decoding to URL Encoded Characters?
I would like to save this file with this URL "http://pti.regione.sicilia.it/portal/page/portal/PIR_PORTALE/PIR_LaStrutturaRegionale/PIR_AssessoratoEconomia/PIR_DipBilancioTesoro/PIR_Areetematiche/...
3
votes
3answers
736 views
awk/sed part of filename
I want to awk/sed only prefix of name of files, whenever I put a filename as a parameter to my command line.
For example,
I have multiple files:
a.fastq.gz
b.fastq.gz
c.fastq.gz
d.fastq.gz
If I ...
0
votes
1answer
85 views
How to sort files in unix
I have files in the following manner
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
...
-4
votes
2answers
271 views
Finding specific string in XML file and storing in another file [closed]
Text in input file is like this
<title>
<band height="21" isSplitAllowed="true" >
<staticText>
<reportElement
x="1"
y="1"
...
0
votes
1answer
483 views
Hebrew (Unicode) file-name support on CentOs 7
I have a VPS with CentOS 7 installed.
I am trying to upload to the server a file that has a Hebrew name.
I tried to upload it via FTP (Pure-ftpd) and I get: Failed to convert command to 8 bit charset.
...
6
votes
4answers
5k views
linux find command for filenames without extension for unknown extensions
I like using the following command to print file names but it prints them with extensions.
find . -type f -printf '%f\n'
In my directory, there are many files with different extensions. I tried ...
0
votes
2answers
187 views
Remove part of name after regex
I have a number of video files using a naming scheme like
some-words-SxxExx.extension
which is my preference. Unfortunately I have a lot of files in this format
some-words-SxxExx-words-I-want-to-...
1
vote
2answers
439 views
How do I find a file whose name has five digits, in a row, somewhere in the file name?
Normally, I would ask a professor or classmate this, but as it's a Saturday and everyone is gone. I have to find a file in a directory that has five digits in a row somewhere in the file name. They ...
1
vote
1answer
45 views
Find a filename in a directory excluding zeros that appear in the beginning of the filename
I have a directory with file names as " 202.png, 405.png, 0052.png, 04050.png, ......
I need a find command to find filenames excluding zeros that appear in the beginning of the file name.
For example ...
10
votes
4answers
4k views
Move all files NOT ending with .txt [duplicate]
In the directory /home/username/data I have both files and directories. Some of these filenames end in .txt (to which I'll refer as text files), others don't. The same happens in the subdirectories.
...
1
vote
4answers
1k views
Count the number of files and folders containing a certain string
Let's say I'm in the Desktop directory and want to count the number of files and directories whose name is exam. It should also count the files containing the string exam. So to sum it up I need to:
...
0
votes
5answers
440 views
Renaming files by extracting parts of filenames that match with a pattern
I want to know which command I can use to rename files like this.
Let's say, for instance, the old filenames are:
0_predict-1-500.png
0_predict-2-500.png
0_predict-3-500.png
1_predict-1-500.png
...
3
votes
2answers
1k views
Bash - replace spaces with underscore but replace multiple spaces with one
I use rename to underscore spaces in filenames, simply with:
rename "s/ /_/g" *
but I encounter the problem that files downloaded from the internet often have multiple spaces. A nasty workaround I ...
26
votes
3answers
2k views
Why does awk stop and wait if the filename contains = and how to work around that?
awk 'processing_script_here' my=file.txt
seems to stop and wait indefinitely...
What's going on here and how do I make it work ?
0
votes
1answer
47 views
Reading full Names in an Archive or ISO image?
I recently installed Ubuntu 18.04 on my Laptop wanting to learn Linux. I have some Video Courses in ISO Images; whenever I want to extract files from them, I don't get full names for some reason. I ...
1
vote
1answer
4k views
Linux grep for file starting with certain letter AND contain certain words
Trying to search a file directory for file names beginning with "h" and containing "enu"?
So far this is what I've got, I just don't know how to handle both grep statements in one command line?
find ...
1
vote
1answer
266 views
Remove files in linux with different folder files to delete in a folder as particular folder
I want to remove multiple (all) files with different suffixes (.log,.bin) in a particular directory (/home/username) in a one-line command. How could I do that?
0
votes
2answers
265 views
Want to edit a file content for Removing the string after the last underscore and before the file extension using Unix commands
I want to edit the file contents in the 2nd row and 2nd column ,which is a file name from that I want to remove the part after the last underscore and before the file extension .
The contents of the ...
0
votes
1answer
463 views
Rename multiple files using sed command after removing the string after the last underscore [closed]
I have a set of files in a directory as shown below and I want to remove the string after the occurrence of the last underscore from it. The string may be different each time. It will be good if it ...
1
vote
3answers
70 views
Sorting filenames uniquely
I have searched for the solution but couldn't find answer to my problem.
I have thousands of file in a directory. Filenames are in the below format
74687_1543944930857.txt
74687_1543945090451.txt
...
0
votes
1answer
81 views
Check that 2 arrays of file names are the same
So I have the following:
cat file | grep -E regex
which gives a list of lines
Now I also have a for loop the produces a list of files
So it is like I have 2 arrays.
But how do I check in bash if ...
0
votes
2answers
794 views
Rename Files to Same Filename Without Extension with find Command
I'd like to rename a group of files to their same filename but without extension. They are scattered in my home directory and I don't know where they are located precisely, but I do know the extension ...
0
votes
2answers
291 views
How can I change lower to upper using (three) parameters in bash? [closed]
I have to make a bash script that will be changing files' names from lower to upper OR from upper to lower via parameters in command line. So when I put in command line:
./bashScript lower upper
...
0
votes
1answer
336 views
Eliminating multiple-extension file names from find output
I need to find the size of all files in /etc with the .conf extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 {} +, but find gave me .conf files that have two or three ...
0
votes
2answers
118 views
delete then rename: same filenames different extensions
I have a directory containing thousands of files, each file has a duplicate.
An example:
file1.txt
file1.jpg.txt
file2.txt
file2.jpg.txt
I want to delete all *.txt files, and leave the *.jpg.txt
...