32 votes
Accepted

PowerShell: How do I append a prefix to all files in a directory?

An alternative approach to a regular expression would be to use simple string operations to create the new file name. $items=Get-ChildItem; $items | Rename-Item -NewName { "Prefix_" + $_....
Seth's user avatar
  • 9,195
21 votes

How do I rename a session in tmux?

From within tmux you can also edit the name of the current window (one of many within the session) with: Prefix, then comma sign: Ctrl + B, , (This does not rename the "session", but the window ...
rubo77's user avatar
  • 4,920
18 votes
Accepted

How can I skip a cycle in a FOR loop?

Just place a label :nextiteration (or whatever other name you like) as the last statement inside the for-loops body and goto to that label when you decide that you can skip the rest of the for-body. ...
Tonny's user avatar
  • 31.6k
17 votes

Windows bulk rename middle filename via CLI?

This PowerShell one liner will expand all numbers in the file name to two places .PadLeft(2,'0'): (and leave numbers with more places untouched) Get-ChildItem *[0-9]*.txt|Rename-Item -NewName {([...
LotPings's user avatar
  • 7,241
14 votes

How to remove trailing characters in filenames in Bash?

In shell, one could do simply: for x in *]*.avi ; do mv -i "$x" "${x%]*.avi}.avi" done The shell can produce a list of the filenames with just a regular glob, and ${var%pattern} removes the (...
ilkkachu's user avatar
  • 1,221
14 votes

PowerShell: How do I append a prefix to all files in a directory?

You are quite near. -replace uses RegEX and in a Regular Expression you anchor at the beginning with a ^ for a suffix you can similarly replace the anchor at line end with $ to avoid any possible ...
LotPings's user avatar
  • 7,241
13 votes

Windows filename suddenly gets selected again while renaming it

Hello from the year 2020. I found out that it is a Google Drive sync issue (the product was renamed to “Backup and Sync from Google” meanwhile). You can test it yourself: Click on the Google ...
Avatar's user avatar
  • 2,684
13 votes
Accepted

Windows bulk rename middle filename via CLI?

Would it be possible to bulk rename it with Windows ren or rename tool? Yes, but it requires a batch file. test.cmd: @echo off setlocal EnableDelayedExpansion for /f "tokens=1,2,3,4" %%i in ('dir /...
DavidPostill's user avatar
  • 157k
11 votes

How can I remove the first character from all filenames in a folder?

Forget about complicated scripts for this. rename is a very old and never properly completed command.  If you do not use it properly, the result might surprise you. For example to remove a prefix ...
anonymous's user avatar
  • 111
11 votes

Is there a way to batch rename files to lowercase?

Here is a proper recursive command line solution using only native cmd.exe commands that actually works. I believe it is the simplest possible native solution: for /r %D in (.) do @for /f "eol=: ...
dbenham's user avatar
  • 11.4k
9 votes

Is there a way to batch rename files to lowercase?

"Recursive" version of the accepted answer (that works*) for /f "Tokens=*" %f in ('cmd /c "echo %cd%& dir /l/b/ad/s"') do (for /f "Tokens=*" %g in ('dir /l/b/a-d "%f"') do (rename "%f"\"%g" "%g"))...
wc.matteo's user avatar
9 votes

Batch rename Chrome bookmarks

Export bookmarks (Bookmarks->Bookmarks Manager->Click column in upper righthand side that has 3 vertical dots->Export Bookmarks) Make a backup of the bookmarks file incase you mess up Open the file ...
BoldAsLove's user avatar
9 votes
Accepted

How to remove trailing characters in filenames in Bash?

This will rename the files. You need the \w* to signify any number of alphanumeric characters. rename 's/\]\w*//' * Reference: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm#...
James Nuanez's user avatar
8 votes

Mass Remove File Prefix on a Mac?

A quick visit from the year 2019 to give an update. osX has something like this built into finder now. Open finder Select all the files you want renamed From the right-click menu (or File menu) ...
tbernard's user avatar
  • 181
8 votes

How to omit characters at the beginning of a filename while renaming it in Windows cmd?

Forget about complicated scripts for this. rename is a very old and never properly completed command.  If you do not use it properly, the result might surprise you. For example, to remove a prefix ...
Andrew Ion's user avatar
7 votes

How to add missing file extensions for multiple files using ExifTool in Windows

For Windows, the command line to append file extensions where they do not exist (using free downloadable utility ExifTool): exiftool -r '-filename<$filename.$filetypeextension' -ext . <yourdir&...
Brian Murphy's user avatar
7 votes
Accepted

Renaming a batch of folders to follow a certain pattern

PowerShell ( executed from parent folder ): Verbose: Get-ChildItem -Directory | Where-Object Name -match '^\d{1,2}$' | Rename-Item -NewName { '{0:d3}' -f [Int]$_.Name } KeyBanger: gci -ad | ?...
Keith Miller's user avatar
  • 9,650
7 votes
Accepted

How can I use Powershell to rename all files where the name has the format "digits [space] name with spaces" to "digits [hyphen] name with spaces"?

Try the following cmdlets: gci -Recurse -file | where { $_.Name -match '^\(?\d+\)? .+' } | Rename-Item -NewName { $_.Name -replace '^\(?(\d+)\)? (.+)' , '$1-$2' }
Reddy Lutonadio's user avatar
6 votes
Accepted

How to rename file during copy in command prompt

That's pretty straightforward with the copy command: copy folder1\1.txt folder2\2.bat
simlev's user avatar
  • 3,822
6 votes
Accepted

Windows Explorer doesn't show updated names when changing capitalization (multiple files via script)

A script like this could help you: $windows = $(New-Object -ComObject Shell.Application).Windows() $windows | ? { $_.FullName -eq "C:\Windows\explorer.exe" -and $_.LocationURL -match "$...
Destroy666's user avatar
  • 6,802
5 votes
Accepted

When renaming a file in Windows, CTRL + Backspace does not delete whole words

So the reason for that happening (the box appearing) is that it's a control character. It's one of the several ASCII non-printable characters. Look into AutoHotKey to override the default behavior of ...
ivanempire's user avatar
5 votes

How do I rename C:\Windows\System32\convert.exe?

It is usually not a good idea to rename system files (or change their NTFS permissions, after the next OS-Update this may be reversed back). Ideally contact your Software vendor (for ImageMagick) to ...
Peter Hahndorf's user avatar
5 votes
Accepted

How to rename my folder and any of its subfolders into lowercase using command prompt in Windows?

It's much easier to use PowerShell instead of the legacy cmd Get-ChildItem -Directory -Recurse | Rename-Item -NewName { $_.Name.ToLower() } -WhatIf Shorter version ls -Di -R | ren -Ne { $_.Name....
phuclv's user avatar
  • 27.9k
4 votes

Windows filename suddenly gets selected again while renaming it

I have ran into this today, its definitely caused by OneDrive for me. Accepted "answer" (turn off Media Features) from microsoft did not helped. But simply existing OneDrive fixed it. So was ...
c69's user avatar
  • 221
4 votes

Recursively rename files (change extension) in Linux

I found this method is easier and easier to read: find . -name "*.andnav" | rename "s/\.andnav$/.tile/" At least on Ubuntu derivations rename takes a list of files from STDIN if none are on the ...
Bernd Wechner's user avatar
4 votes

How do you change a TTF font name?

Per this answer on StackOverflow: Import your font file in the online Glyphrstudio font editor Click the hamburger icon on the top left Select font setting and change title and meta data from there
Steven Pease's user avatar
4 votes
Accepted

Set name of Konsole window

you can add a bash function at the end of your ~/.bashrc title() { echo $'\033]30;'$*$'\007' } (after saving .bashrc remember to type in the console: . ~/.bashrc to add the function to your shell, ...
Lucio M. Tato's user avatar
4 votes
Accepted

why does Powershell tell me that my file represents a path when I try to rename it?

The correct escape character in PowerShell is ` (the back tick). E.g. you would write the following to get a string with a newline: $newline = "`n" In addition, at least in a test, I didn't need ...
Seth's user avatar
  • 9,195
4 votes

Delete duplicate images with different file names

I found an app that does this; it's called VisiPics: http://www.visipics.info/ VisiPics does more than just look for identical files, it goes beyond checksums to look for similar pictures and does ...
Vincent Tang's user avatar
4 votes
Accepted

How do you rename an installed application in Windows 10?

The Uninstall name is stored in the Windows Registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\... and/or HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\...
DrMoishe Pippik's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible