Questions tagged [filenames]

File name is a name used to identify a file uniquely on given file system.

Filter by
Sorted by
Tagged with
1
vote
1answer
27 views

zgrep a column and print the matching filename

I am trying to match pattern for a particular column in the thousands of gzipped files on a Linux machine, and based on the match I want to print the file name how to do that. Below options are not ...
1
vote
1answer
60 views

filenames with ' in, (we're) is messing with my script

I have a script that first move the selected files into a temp directory,scans the directory, takes the largest file and create a new directory with that name, and moving all files to the newly ...
1
vote
1answer
64 views

Sort files in directories based on filename

I have > 35,000 scanned diapositives from a scientific archive in one directory. (Fortunately, the filenames are rather uniformly formatted: {year}-{place}-{film-#}-{photo-#} OR {year}-{year}-{...
0
votes
3answers
46 views

How to test if one or more files with a prefix exists in bash? e.g. [[-f foo*]]

Is there a way to use a Filename Expansion within a test expression, more specifically, a bash conditional expression? For example: [[ -f foo* ]] && echo 'found it!' || echo 'nope!'; ... will ...
0
votes
1answer
55 views

How to change end of filename

I am using Mac Terminal and I need to delete end of filename. Example of filename : 1516092009.M432844P7000.camel5,S=14022,W=14295/2, I need to delete the end /2, and I tried command: rename 's/\/2,//...
0
votes
1answer
18 views

swap fields in file names

How can I do the following change in file names. I suppose this is possible with rename, but I do not know how. A_B_C.pdf to C_A_B.pdf A, B and C are different words in my file names, like ...
1
vote
1answer
43 views

How to replace part of a filename with input from stdin?

Let's say I've got a file ids.txt with several entries like foo bar bam ... for example. I'd like to use this as input to run a command on some files containing the ids in the filename like foo_1.gz, ...
1
vote
4answers
59 views

String substitution to detect empty variables?

I have a script that iterates through files and does some string substitution to insert the date. #!/bin/bash f="/tmp/file.txt" # with .txt extension timestamp="$(date +%H%M%S)" ...
2
votes
2answers
57 views

Why tar uses absolute path even though I have changed to dir via -C?

Having this: $ls $des/bin a.c analysis.hpp classify.hpp main.cpp split.hpp a.cpp a.out grade.cpp main.out student.cpp analysis.cpp classify.cpp grade.hpp ...
4
votes
3answers
504 views

Files names with an ' (apostrophe) inside of them

When I list files that have spaces in their names, most of the time I see them surrounded by apostrophes : 'famille, vacances, loisirs' I had to edit a file whose name had to be : Chapitre 2 : L'accès ...
0
votes
2answers
36 views

Compare multiple file suffixes containing date & time and do action on most recent

I have multiple files in a directory that follow the below pattern. logA.log.$todayDate.$timeCreatedlogA.log.07222020.084355 I want to compare the $timeCreated part of all the files in the directory ...
1
vote
1answer
71 views

Find filenames that contain number

I would like to find file names which contain a number and list them in a range of numbers. For example, in my directory I have: ** Ion_001_rawlib.bam Ion_002_rawlib.bam Ion_003_rawlib.bam ...
1
vote
2answers
52 views

How to find directories (or files, etc.) based on an expression that applies to the file pathname [duplicate]

I'm trying to find/extract directories based on an expression that applies to the file path. For example, I used the command: find . -type d -links 2 To get a list of directories that looks something ...
0
votes
1answer
20 views

Disable bash autocompletion for combinations of specific commands and specific filetypes

In the current directory, if we have a C++ source file, hello_world.cpp and the corresponding compiled executable binary hello_world, I'd like to have the autocomplete feature of bash to completely ...
0
votes
1answer
16 views

rsync cannot exclude relative files?

I know the exclude option in rsync can only accept relative paths, so I though I can make workaround with realpath --relative. $ls /usr/local/bin cppman demangle e fusuma rem triangle $realpath --...
3
votes
3answers
442 views

How do I rename multiple files by removing everything but numbers?

I want to rename files like: SL Benfica vs. SC Beira-Mar 136.mp4 SL Benfica vs. SC Beira-Mar 137.mp4 SL Benfica vs. SC Beira-Mar 138.mp4 SL Benfica vs. SC Beira-Mar Jogo 074.mp4 SL Benfica vs. SC ...
-4
votes
2answers
49 views

Taking a specific part of the file name with shell script and put into loop

Let me explain, .SAC files are type of seismograms which SAC ( Seismic Analysis Code ) program use and the other files which contains *HH are response files. I want to remove insturment response which ...
2
votes
2answers
36 views

Renaming file name with shell script

I have lots of file name like below; KO.ADVT..HHE.D.2017.163.121959.SAC KO.ADVT..HHN.D.2017.163.121957.SAC KO.ADVT..HHZ.D.2017.163.121959.SAC KO.ARMT..HHE.D.2017.163.121957.SAC KO.ARMT..HHN.D.2017.163....
0
votes
1answer
19 views

How to list and put log's name to a file according to date

I have bunch of log files. And some of them are rotated. Say I want to put their name in a txt file. -rw-r----- 1 admin staff 5120126 Apr 20 14:29 access.log00071 -rw-r----- 1 admin ...
0
votes
2answers
34 views

rename a dynamic generate file which contains BASIC

how can i use rename of mv shell command to rename a file where i don't know the exaxt name of but which contains always de word BASIC rename Ex2WebR1_0WEBSHOP01_005443_B_BASIC.XML BASIC.XML I have ...
-3
votes
2answers
54 views

Shell replace forward slashes with backslashes [duplicate]

I have a question: how to replace forward slashes with backslashes? I have string: App/Models And I need App\Models Thank you very much
0
votes
2answers
34 views

How do I output a command that acts on multiple files, to multiple files?

I am attempting to use the objdump command to disassemble all files in the current directory with the .o extension, and then put the output of this command for each .o file, into a .txt file with the ...
0
votes
1answer
25 views

What is The Best Approach to Duplicate File into Different Filename and Modify The Content in Unix?

I've been doing research for Unix Script these past 2 days. Since I never touch Unix script before and suddenly I need to create Unix script to support my program. Basically I would like to seek an ...
2
votes
3answers
49 views

Tool to rename files with some logic involved

Any command line tools to rename files that don't already contain a string or a set of strings to then include that string? So all files in a given folder should have high in the name for "high ...
0
votes
0answers
46 views

Does pipe change filenames? [duplicate]

I do this command: $ locate config.yml | while read i; do sed -i '/(swipe)|(pinch)/s/[0-9].*/1/' $i; done output: sed: couldn't open temporary file /home/user/.config/fusuma/sedHhlVCW: Permission ...
1
vote
2answers
51 views

awk passing variable, files with spaces

I am new and I have small problem and I couldn't solve it by myself. Here is the issue that I am faced with: I am trying to find the files with spaces in their names. This part is working: find $(...
0
votes
3answers
39 views

Naming files with decimal numbers in BASH

I want to name my files with the step in which they were created. The step size is in decimals and as far as I know dealing with decimals in bash is difficult. This is the code: for i in $(seq 0.05 0....
3
votes
1answer
42 views

sort part of the name

I have multiple names that have the same prefix but the prefix is unknown. I want to sort only by the digits in the name. i.e abcd_006-123 abcd_006-232 bbcd_w_006-112 so bbcd_w_006-112 should be ...
1
vote
2answers
51 views

ffmpeg across .avi files in subdirectories

Situation: Running macOS 10.13.6 and using bash 5.0.17(1) A lot of subdirectories which hold multiple files. Need to filter out files in subdirectories with a specific extension (.avi). Need to ...
0
votes
1answer
69 views

Encrypting home folder without filename encryption using `ecryptfs`

ecryptfs encrypts home folders with filename encryption by default. However, because of this, filenames with more than 143 characters can not exist in the home folder (while an unencrypted ext4 home ...
0
votes
2answers
24 views

replace multiple strings in a file using ksh

I have a directory in which all the files are listed with .ear. I want to remove the .ear and keep only the file name. Is I possible? When I try cd /path/ ls >> file then in the output file ...
0
votes
2answers
31 views

remove repeated names on file names

I have many files on my Linux machine with file names like this: Veillonella-sp.-AF13-2-AF13-2.Scaf1.faa Weissella-cibaria-strain-AM27-24-AM27-24.Scaf1.faa Streptococcus-salivarius-strain-AF24-6AC-...
1
vote
2answers
119 views

How can I batch rename text files to be the first word in each text file?

I need to rename a few thousand text files to be the first word in the text file plus the file extension (.txt) using the terminal. All the files are in a single directory, and are currently named int ...
0
votes
1answer
29 views

Concatenating Files based on first characters of file names

In a folder I have files like below. COUNTRY_US_20200401.TXT COUNTRY_GB_20200401.TXT COUNTRY_FR_20100328.TXT COUNTRY_US_20200406.TXT COUNTRY_GB_20200410.TXT I want to check for first 10 characters ...
0
votes
1answer
31 views

Move all files of certain filetype in all sub directories up one level

I have a directory with lots of sub-directories. The sub-directories each have unique names. I would like to take every file ending with '.nc' in the sub-directories and move those files up one level....
5
votes
4answers
309 views

how to keep a filename with only 20 characters and a file extension .txt

I have a bunch of files like this: hhsLog.8020.20200330}1585594173}0}coll_DefaultCollectorGroup_1_158594166_132642}1036942}0}0 I just want to keep the first 20 characters and add a .txt extension. ...
0
votes
1answer
42 views

Using grep --exclude-dir on OSX

I am trying to find a file that contains the text "The default interactive shell". I am trying to use the following grep command to find it: grep -r --exclude-dir='/{var,Volumes,bin,cores,dev,sbin,...
3
votes
3answers
308 views

Convert only parts of a filename to uppercase

In a shell script program, I need to convert the filenames to uppercase if the converted filename does not already exist. In this particular case I need to change only the basename to uppercase ...
1
vote
0answers
24 views

Some files in CIFS directory cannot be overwrite once created/copied

I have encountered a strange behavior in one of the CIFS mount directory. For example, I copy a file to the directory, cp /mnt/source/movie.mp4 /mnt/target/ . First time it runs successfully. But when ...
1
vote
1answer
57 views

zsh completion rules - remove file extension from completion result

I am trying to create simple zsh completion rules for a password manager script pass. pass stores its passwords in directory structure, the files itself are .gpg files. I want to complete ...
0
votes
2answers
43 views

Copy a file containing date in the file name to a folder for that date

I looked for similar questions, but it was hard to get a clear answer in my case. I use my synology DS1515+ and DSM 6.2.2. First of all, I have been made daily folder containing a date using script ...
0
votes
1answer
30 views

How to remove specific section in filename

I use my synology DS1515+ and DSM 6.2.2. I'd like to remove specific section in name of many files. For example; abcde(test).mp4 → abcd.mp4 love(1).mp4 → love.mp4 Section that from ( to ) in ...
-1
votes
3answers
88 views

how to remove string in multiple file name after a specific character?

I have multiple file in a folder with this format of name 01. file one-sdvanv-12lknl.srt 01. file one-sdvanv-12lknl.mp4 02. file two-afdsmakl-asdfafdaf.srt 02. file two-afdsmakl-asdfafdaf.mp4 03. ...
0
votes
2answers
33 views

Find commonality/pattern in a bunch of files

Let's say, I have a folder with hundreds or thousands of files, all named after the following schema: <random number of variable length>_<date code in YYYYMMDD format>.jpg Example: ...
1
vote
1answer
164 views

How can I make realpath never resolve symlinks?

I'm looking for a command to return the absolute path of a file, without resolving symlinks. In general, realpath does this well. $ mkdir /tmp/test; cd /tmp/test $ mkdir foo $ ln -s foo bar $ ...
2
votes
3answers
74 views

Copy a file containing a date in the file name to a folder for that date

I'm newbie in stack overflow. I need your help. Thank you for your reply in advance. I looked for similar questions, but it was hard to get a clear answer in my case. I use my synology DS1515+ and ...
3
votes
2answers
51 views

File name character encoding gets confused when called with find -exec

I'd like to simplify the example, but any further simplification removes the problem … I already stripped my script down to this: #!/bin/sh echo "$1" | sed 's/[^[:alnum:]]//g' This does what I ...
2
votes
3answers
103 views

Pad file names so Unix lists them in numerical order

I have a folder with several files formatted as follows: C Block Scan copy 1.pdf C Block Scan copy 2.pdf C Block Scan copy 3.pdf C Block Scan copy 4.pdf . . . One issue I'm having is that when I run ...
1
vote
2answers
89 views

Can't remove directory with weird name [duplicate]

While creating a new folder I didn't realise that in BASH ' is a special character, which means I ended up with a folder named One Flew Over the Cuckoos\ Nest\ \(1975\)?quit?quit()?ls?????????? or ...
0
votes
1answer
65 views

Sort files based on similarity of file names

I have a directory structure which contains many files. I want to find similar files recursively and sort them based on their names. The easy part: find all files named f*.ext and move them to a ...

1
2 3 4 5
21