![]() Recommending a hardware/software solution as a comment to a post is acceptable. We do not allow posts asking for recommendations on hardware/software or recommendations comparing two or more hardware/software. We are not a recommendation or advertisement subreddit. Please do not take advantage of the community. This community is "free" as it is full of volunteers. No Amazon gift voucher or PayPal transfer. No offering of reward/compensation for solutions. Issues with account lockout on any of the above platforms (and all others) ![]() Google, Apple, Microsoft, Instagram, Facebook or any other account Password Only support for the related account can help you. Do not message us asking us to make an exception. We cannot assist with password or account issues. Please make your title and contents descriptive. Posts with "Help" or non-descriptive titles. ![]() Posts with an empty body, only a link in the body, title copied into the body, and/or lack of information in the body Submissions consisting of the following are considered incomplete and will be removed: Please read our new rules page for more in-depth rules. Please do not submit the same issue more than once within 24 hours. Do everything you can to reduce the effort of the wonderful folks offering to help you.Īfter solving your problem, please mark it as solved by clicking 'flair' and confirming the 'solved' tag. State everything you have tried and all the guides/tutorials/sites you have followed as well as why they were unsuccessful. Try to research your issue before posting, don't be vague. The subreddit is only for support with tech issues. Please include your system specs, such as Windows/Linux/Mac version/build, model numbers, troubleshooting steps, symptoms, etc. Live Chat ~Enter Discord~ Submission Guidelines Useful for testing.Check out our Knowledge Base, all guides are compiled by our Trusted Techs. The -n causes rename to simply print what it would do and not actually do anything. In all examples, remove the -n to make them actually do something. If you don't want that, be careful where you tell it to recurse, or give it a more specific pattern like *.txt. Note that all of these solutions will cheerfully rename directories as well as files. To limit it to only files or directories with extensions, use **/*.* instead of **.Īlternatively, use find: find /path/to/dir -exec rename -n 's/\b(. ?)\b/\u$1/g s/(.*)\.(.)/$1\.\l$2/' Now, run the rename command like this (this will also work on any files in your current directory): rename -n 's/\b(. ?)\b/\u$1/g s/(.*)\.(.)/$1\.\l$2/' ** If your shell is bash (if you don't know, it probably is), you can use the globstar option which makes ** match 0 or more subdirectories: shopt -s globstar and the extension with the first letter lower cased again ( \l$2). We replace the match with everything before the extension ( $1), a. , after which will be the extension (if any). ![]() This means the longest string until a final. is greedy, so it will find the longest possible match. These are then replaced with the capitalized (first letter capitalized) version of themselves ( \l$1). Since it is anchored by word boundaries ( \b), this will find all words (all because of the final g). ? is a non-greedy pattern, which means it will find the shortest possible match. The trick is to first capitalize every first letter, ignoring the extensions, and then go back and make the extension lower case: Justonelongfilename.ext -> Justonelongfilename.ext Is there any way to amend the first rename command to ignore the extensions and leave them as lowercase? Can I run the new command in a higher level directory, and have it recurse through all the sub-directories? If it does matter, then I could copy them to my local drive first, run a command in Ubuntu, then move the files back if required. I don't think this will matter, but the files are on a Windows server fileshare, but I am accessing it using Ubuntu 16.04LTS. I ignore the 'Can't rename *.Txt *.txt: No such file or directory' errors, and if I find an extension that is missing, I just add that line to my script. To get around that issue, I created a small script that looks like this (don't laugh!): #!/bin/bash Which works okay if most of the files in a folder are the same extension (generally true),but is a pain if they are very mixed. That works fine, but it also capitalises the first letter of the extension, so I use this to fix that: rename 's/\.Txt$/.txt/' *.Txt I am using this on a customer's directory to rename files with first letter of each word being capitalised as per their request:
0 Comments
Leave a Reply. |