Questions tagged [filenames]
File name is a name used to identify a file uniquely on given file system.
1,188
questions
0
votes
1
answer
31
views
Need help with ls and escape characters
I'm trying to create a bash script to run the ffmpeg command on every file in a directory with filenames that contain spaces. This is the script that I started with to do an individual file which ...
0
votes
0
answers
19
views
Some files have truncated filenames with mkisofs -J -R [migrated]
I have installed mkisofs 3.02a09 (i686-pc-mingw32) on Windows 10.
I'm trying to create an ISO with mkisofs but some filenames are truncated :
PS C:\tools> mkisofs -J -R -o VDI-Michelin-Editions-...
0
votes
2
answers
18
views
How to open a file starting with dash via xdg-open
Usually, a double dash separates options from filenames, but xdg-open does not care:
❯ xdg-open -headlinesAfter.epub
xdg-open: unexpected option '-headlinesAfter.epub'
Try 'xdg-open --help' for more ...
1
vote
1
answer
21
views
Convert directory with opus files to CSV or similar?
I have a folder with opus sound files. I would like to convert that folder listing to something I can use in a spreadsheet. I want the result to contain something like file name, length of the sound ...
25
votes
3
answers
5k
views
Is it now safe to parse the output of GNU ls?
The accepted wisdom for the past few decades has been that it is never a good idea to parse the output of ls ([1],[2]). For example, if I want to save a file's modification date along with its name ...
2
votes
1
answer
68
views
Change Filenames Based on List in .txt file in Terminal
I'm trying to rename a bunch of audio files. They are named "1 Audio Track.aiff" and so on. I have a .txt file with the old filenames and the new filenames separated by a tab. For example, ...
1
vote
3
answers
61
views
ls starting at particular file
How do I ls files in a directory beginning with a particular filename?
For example, if my CWD has these files:
$ ls -1
alpha.mp3
bar.xls
file1.txt
file2.txt
foo.odt
testing3.txt
How do I print out ...
0
votes
1
answer
24
views
Copy multiple files by filenames in subdirectories in linux
I can do the following to copy a file from subdirectories.
find . -name "file1.txt" -type f -exec cp {} ./distfolder \;
How do I change this code to copy multiple files (file1.txt, file5.txt,...
2
votes
3
answers
97
views
Sort a list of filenames such that files in subdirectories are listed before files in the parent directory
I have a text file containing a list of files, such as:
file
A1/file
A1/B1/file
A2/file
How can I sort it such that files in subdirectories are listed before other files in the parent directory?
A1/...
0
votes
1
answer
53
views
How to copy files from a list without extension to a different folder?
I have a text file that contains a list of ids of files without any extension now I need to copy those files mentioned in the list
head 01cBC.txt
EE87786
EE87787
EE87788
EE87789
EE87790
EE87791
Now, ...
0
votes
0
answers
22
views
globbering without error [duplicate]
I'd like to globber for files in a bash loop, something like this:
for file in filepattern???; do
# some command
done
But, if there are no files that match filepattern???, then this loop executes ...
0
votes
2
answers
62
views
How to add subfolders from one directory to another directory with the same files unorganized, and prepend folder name to files
I am an R user who is not yet familiar with unix or command line coding. I have a directory with subfolders containing files, and I have another directory with all the same filenames and no subfolders ...
0
votes
2
answers
115
views
Dangers of executable file with '#' in name?
This might be a FAQ--happy to have the question closed if it's a dupe--but I'm not sure how to find it if so. I'd also be happy with an answer that simply told me how to find the relevant ...
1
vote
1
answer
111
views
How can I rename files recursively using a regular expression
I have hundreds of files on a hard drive with many directories and sub directories which start with:
1.1, 1.2, 1.3, 2.1, 3.1, 9.1, 10.1, 10.2, Etc Etc...
The problem is that when I list them they ...
0
votes
1
answer
335
views
Write directories, subdirectories and file names to .txt file
I am looking for a command that will write the names of all directories, subdirectories and file names to a text file.
Example format:
directory1
|_subdirectory1
| |_filename1.mp4
|_subdirectory2
| |...
0
votes
1
answer
117
views
Create file with pipe character ("|") in filename on Ubuntu/Windows11 dual-boot machine
I'm running Ubuntu 22.04 and would like to create a file having the pipe character ("|") in its filename. (Necessary to run some legacy code.) Specifically, how do I identify and correct ...
0
votes
2
answers
61
views
Delete files with similar names
I have been away from scripting for years, so I was wondering if someone can help in the below.
I am migrating from Google Photos to Amazon Photos (about 40k photos). Here is an example of what I ...
0
votes
1
answer
124
views
Winrar error: Attempting to correct the invalid file or folder name
Posting this since I could not find it using Google and this took weeks.
When extracting using Winrar, I am getting
! Attempting to correct the invalid file or folder name
! Renaming C:\Users\noam.s\...
0
votes
1
answer
137
views
Testing whether variable has valid video file extension
How can I test whether a variable has a valid video file extension (.mp4) ?
1
vote
3
answers
128
views
How do I find the directory with the longest path?
How can I find the directory with the longest path (contains the largest number of subdirectories) , in the current directory , using ls ~ -R commmand
-2
votes
1
answer
300
views
how to create a directory that already exists with another name
i want to create directory called "A" inside my home directory but i don't know if such a directory already exists. i want to write a command that creates the directory if it does not exist. ...
1
vote
0
answers
114
views
What does it mean when a file isn't detected with a wildcard search? [closed]
I have three files in a folder: trace-0.fits, trace-1.fits, trace-2.fits.
When I run:
ls trace-?.fits
Only trace-0.fits and trace-2.fits are detected. But:
ls trace-1.fits
Detects trace-1.fits, as ...
0
votes
1
answer
83
views
Remove all bracket types and any strings within them from all files in a directory
I have thousands of really old video files that have brackets of all types strewn in them in no particular order. I'm trying to "clean" them, that is, rename these files so that all the ...
0
votes
0
answers
27
views
Is there a useful utility for managing multiple "alternatives" of a given file?
The example I'm going to give here is a simple media file conundrum.
In this example, say I have multiple versions of a given audio file:
SomeSongLibrary/
awesome-song-compressed.mp3
awesome-...
11
votes
3
answers
1k
views
What is the difference between locate txt vs locate *.txt?
Output of locate txt | head:
/etc/brltty/brl-ba-all.txt
/etc/brltty/brl-bd-all.txt
/etc/brltty/brl-bl-18.txt
/etc/brltty/brl-bl-40_m20_m40.txt
/etc/brltty/brl-ec-all.txt
/etc/brltty/brl-ec-spanish.txt
...
0
votes
2
answers
111
views
Need help with a command to find all filenames that are too long and delete from a directory
I have been using the following command:
find . | awk 'function base(f){sub(".*/", "", f); return f;} \
{print length(base($0)), $0}'| sort -nr | head -2
It will find some files ...
0
votes
3
answers
65
views
Is it wrong to do tar czf somename.tar some_*_files?
Is it wrong to do tar czf somname.tar some_*_files instead of tar czf somname.tar.gz some_*_files, then of course tar xf somename.tar? That is : without adding the .gz extension.
This question is ...
0
votes
1
answer
47
views
How to find and manipulate files that contain newline in filename?
follow up on How to find files that contain newline in filename? ,
I need to do some manipulation on the result, for simplicity lets suppose I need to chown them.
Tried following, but does not work:
# ...
1
vote
3
answers
155
views
Removing directories with spaces in their directory paths
I'm on macOS. I have many directories at paths that looks like this:
./FirstName SecondName/A Multi Word Title/Contents/Index/files
I want to remove ALL the Index directories and their contents. I ...
2
votes
1
answer
180
views
How can I paste full path strings in the GNOME File Selection Dialog on RHEL?
I have a remote RHEL machine which I use via X11. On that machine when I open a new file in, say, VS Code or in the Firefox browser (both apps are on teh remote machine), then I get teh following File ...
9
votes
1
answer
1k
views
What is the meaning of `*(1)*` in a command?
Why use of *(1)* removes everything from a directory? Then how to select all files that has (1) in the middle of it's name?
The command used is rm *(1)* or rm -rf *(1)* (don't remember exactly). It ...
0
votes
1
answer
86
views
Make (`ocrmypdf`) command run in terminal AND include input name in that of the output
I have this line inside a Dolphin service-menu file that contains many other commands for PDF processing:
Exec=bash -c 'f="%u"; ocrmypdf "$f" "${f%.pdf}_ocr.pdf";'
It ...
0
votes
1
answer
171
views
CUPS - Display filename in the Joblist
Is there an option to display the printed filename in the CUPS job list? From the job list, based on the filename user would select the files to be reprinted. Earlier we were able to achieve this when ...
1
vote
4
answers
188
views
How can I remove files that have an unknown number in them?
I have some code that writes out files with names like this:
body00123.txt
body00124.txt
body00125.txt
body-1-2126.txt
body-1-2127.txt
body-1-2128.txt
body-3-3129.txt
body-3-3130.txt
body-3-3131.txt
...
1
vote
1
answer
338
views
Split file with both post and prefix
How can I split file in Linux with number increment between post and prefix
For example
split -b 10M MyImages.tar.gz "MyImages*.tar.gz"
Result
MyImages01.tar.gz
MyImages02.tar.gz
...
0
votes
2
answers
33
views
List and count subdirectories that have files with same name character on string
Picture this:
|-Main_folder
|- Folder1
|- E_1
|- E_1_A
|- file_E_1_A_F_1
|- file2_E_1_A_F_2
|- file3_E_1_A_F_3
|- E_1_B
|- file1_E_1_B_F_1
|- ...
0
votes
1
answer
146
views
Prevent process from overwriting files
The setting
Let's say I have an executable file, let's call it program, whose source code is unavailable (maybe proprietary/legacy).
Each time this program is executed, it generates a file, let's call ...
17
votes
2
answers
4k
views
Can't create files or directories that starts from 'com1' to 'com9'
I can't create folders or files named 'com1', 'com2', ..., 'com9' in my extended hard drive. I'm trying to create a Wine prefix on my other drive where my games are stored, but I get some errors.
...
0
votes
1
answer
28
views
Problem with sample names in the file created using awk
I have some data like below:
dir1
|___dir2
|___dir3
|____files
|____TGH4_1.tar.gz
|____TGH4_2.tar.gz
|...
3
votes
1
answer
177
views
How to find (and rename) files with invalid characters (Latin1) on UTF-8 system?
I've got some old files from a Latin1 based system with names that are invalid on my UTF-8 system. They show as various codes or question marks. For example:
/tmp/test $ ls -1
'FRg_Pause lecture_'$'\...
1
vote
2
answers
218
views
Moving files based on filename
I have folder with .tif files that I want to move based on their filename to a folder with same name.
Example file 123456789_002.tif --> dir 113456789 .
How do I get the first part of the file ...
1
vote
1
answer
80
views
TAB expanding filenames after make command in bash
I'm preparing a makefile for converting org files to markdown files with the use of pandoc. Its content looks like this (note that conversion rule is just for a reference):
%.md: %.org
pandoc -t ...
0
votes
0
answers
181
views
Shell scripting with brackets/parenthesis in folder names [duplicate]
I have a music library that I am trying to restore from backup.
The original source library was on a QNAP NAS and I copied it over to a CentOS system without any problems.
Now that I am trying to copy ...
0
votes
1
answer
174
views
How to remove the dash for multiple files in linux
I'm having files named like HCW-00109-01.sam
I want to change the name of them into HCW0010901.sam
Can someone help me with this?
2
votes
1
answer
646
views
Systemd service prefix on ExecStart=@/path/to/executable doesn't change the `argv[0]`
According to the manual man systemd.service using the prefix @ says this:
If the executable path is prefixed with "@", the second specified
token will be passed as "argv[0]" to ...
1
vote
1
answer
432
views
output filename and 'found string' on same line in output file
Semi-newbie. Trying to automate something using an awk script. Should be simple - in theory.
Set of files, all ending in .lst. In each file there is a single line (out of hundreds) with a particular ...
0
votes
1
answer
56
views
How to add incrementing numbers before file extension .mp3
Aloha from Hawaii,
I hope all is well. In terminal, am trying to make all the filenames of the audio files extensions .mp3, .wav, .m4p, .aiff, .m4a to be unique. I have thousands of them so in order ...
4
votes
1
answer
5k
views
How can I batch rename all files that match a pattern in Linux?
I have folder which contains many .mkv files that I'd like to rename without having to manually do so.
The pattern is this:
...
[XVC]_Control_-_10_-_Doctors_[SCB055Y].mkv
[XVC]_Control_-_11_-...
0
votes
1
answer
65
views
Randomize GIF JPEG and WEBP Filenames
I have a script that randomizes filenames with the JPEG extension:
#!/bin/bash for img in *.jpg; do newname=$(head /dev/urandom | tr -dc a-z0-9 | head -c 8) mv "$img" "$newname"....
10
votes
3
answers
6k
views
What is the practical purpose of "./" in front of relative file paths (in the output from "find")?
Why are some relative file paths displayed in the form of ./file, instead of just file? For example, when I do:
find .
I get this output:
./file1
./file2
./file3
What is the practical purpose, other ...