#!/bin/bash # # 1999_Dec_14 - John Meister # 2014_May_9 - update / 2014_Aug_28 # script to remove spaces in file names and replace with underscore # can be used to change case, or replace spaces only # cleans up web pages by eliminating special characters and sorts properly ############################################### ls | while read -r FILE do # uncomment the next line to change to all lower case # mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'` # uncomment the next line to NOT change case mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | sed 's/_-_/_/g'` done ############################################### # the following only removes spaces in file names: # ls | while read -r FILE # do # mv -v "$FILE" `echo $FILE | tr ' ' '_' ` # done ############################################### ══════════════════════════════════════════ john meister, lab manager, mstm IT systems design and integration specialist Linux, UNIX and lesser OSes ════════════════════════════════════════════ |
The Art of Linux System Administration published by O'Reilly Media Study Guide for the LPIC-2 Certification Exams |
Wagoneers FULL SIZE JEEPS JeepMeister "Jeep is America's -Enzo Ferrari MeisterTech Diesels + |
One Page Overview of Linux Commands click for an image of the 5 essential Linux commands An Intro to Linux |
at Midway Auto on SR9 in Snohomish, or at Northland Diesel in Bellingham, WA |