rename

How can I rename a directory in bash, without overwriting or moving inside a pre-existing target?

不想你离开。 提交于 2019-12-13 20:29:24
问题 I want to rename a directory, only if the target does not exist. To do this the syntax should be mv -n -T my/dir my/dirNew Where -n means "don't overwrite" and -T means "don't move into the target" (https://askubuntu.com/a/763915/461996) Unfortunately, -T is not an option on OSX, so any scripts making use of it won't work for OSX. So, how can I rename a directory only if it won't overwrite one? I've checked, and rename is not a standard I can depend on. 回答1: If its not necessary for you to

Renaming files using regular expressions - Linux

浪子不回头ぞ 提交于 2019-12-13 17:39:33
问题 I have three files named file1.txt file2.txt file3.txt I am trying to rename them to mynewfile-1.txt mynewfile-2.txt mynewfile-3.txt How would I go about this using regular expressions? 回答1: Try this : rename -n 's/^file/mynewfile-/' *.txt or from comments : rename -n 's/^file(\d+)/mynewfile-${1}-test/' *.txt ___ ____ ^ ^ capturing group | captured group (remove -n switch when your tests are OK) There are other tools with the same name which may or may not be able to do this, so be careful.

How do I rename a file to google drive rest api? Retrofit2

半城伤御伤魂 提交于 2019-12-13 14:46:14
问题 In the Google documentation about it is not written, I use retrofit 2. Help. Write what request should be sent and what parameters to transmit interface: @PATCH("drive/v3/files/{fileId}") @Multipart Call<ResponseBody> renameFileGoogle( @Path("fileId")String fileId, @Part MultipartBody.Part metaPart ); call metod: public void renameMetod(String id, String title) { String content = "{\"name\": \"" + title + "\"}"; MediaType contentType = MediaType.parse("application/json; charset=UTF-8");

Batch rename part of a filename from a lookup file

旧城冷巷雨未停 提交于 2019-12-13 12:38:15
问题 edit : see the bottom for my eventual solution I have a directory of ~12,700 text files. They have names like this: 1 - Re/ Report Novenator public call for bury - by Lizbett on Thu, 10 Sep 2009.txt Where the leading digital increments with each file (e.g. the last file in the directory begins with "12,700 - "). Unfortunately, the files are not timesorted, and I need them to be. Luckily I have a separate CSV file where the ID numbers are mapped e.g. the 1 in the example above should really be

How do I truncate the last two characters of all files in a directory? [duplicate]

蹲街弑〆低调 提交于 2019-12-13 09:19:37
问题 This question already has answers here : Bash script to remove 'x' amount of characters the end of multiple filenames in a directory? (3 answers) Closed 2 years ago . So pretty simple question. All of the files in my directory are of the form 6bfefb348d746eca288c6d62f6ebec04_0.jpg . I want them to look like 6bfefb348d746eca288c6d62f6ebec04.jpg . Essentially, I want to take off the _0 at the end of every file name. How would I go about doing this with bash? 回答1: With Perl's standalone rename

Renaming Pictures on a FTP Folder with different Names to 1 File (Override) for a Webcam Feed

此生再无相见时 提交于 2019-12-13 08:59:31
问题 A Client of me had the follwing Problem: He has a Webcam that Uploads Pictures to a FTP Folder. Unfortunaly the Webcam does Upload each File seperatly (Webcam_Eglisauxxxxxx.jpg) xxxxx stands for a Timestamp from the Webcam. There is no Way to achive that the Webcam by herself just overrides the latest file :( Now i Need a php script to check against new Files in this Directory and rename it to a given Name. (Webcam_Eglisau_Image.jpg) I know that this Need the rename function but i have no

C#: Rename/replace duplicates in list with an added number

↘锁芯ラ 提交于 2019-12-13 08:21:41
问题 I have a List<string> where I would want to replace all duplicates with an added number to them. An example would be: {"Ply0", "Ply+45", "Ply-45", "Ply0"} I would like each "Ply0" to have a unique name, so replace them with "Ply0_1" and "Ply0_2" . It is important that the order of the list stays the same. Afterwards the list should look like this: {"Ply0_1", "Ply+45", "Ply-45", "Ply0_2"} I have tried first finding the duplicates with LINQ but I am new to it and also have trouble replacing

matching and reformatting poorly typed filenames

喜夏-厌秋 提交于 2019-12-13 08:14:01
问题 I have a large number of filenames that have been poorly written which I would like to clean up. The idea is to reformat the names so that they are more sensible. Here are some examples: 01harpharm_3.1.aiff 1 01harpmute_2.6.aiff 1 01harpmute_2.6.aiff 2 01harpmute_2.6.aiff 3 01harpmute_2.6.aiff 4 If we look at the last example, the goal would be to rewrite 01harpmute_2.6.aiff 4 as 01harpmute_2.6.4.aiff . I would like to use bash for this, either via a script (for loop), find, rename, or a

Rename Files to include Parent & Grantparent folder - powershell

自闭症网瘾萝莉.ら 提交于 2019-12-13 05:42:46
问题 I have folders that follow the pattern like this: C:\root folder\grandparent folder\parent folder\00001.pdf C:\root folder\grandparent folder\parent folder\00002.pdf I would like to rename the pdfs to something like root folder-grandparent folder-parent folder.1.pdf and root folder-grandparent folder-parent folder.2.pdf etc. and if possible move this file up to the root folder level. I found this powershell script that does something similar but it only takes the parent folder name. This is

Bash script to copy numbered files in reverse order

Deadly 提交于 2019-12-13 05:17:38
问题 I have a sequence of files: image001.jpg image002.jpg image003.jpg Can you help me with a bash script that copies the images in reverse order so that the final result is: image001.jpg image002.jpg image003.jpg image004.jpg <-- copy of image003.jpg image005.jpg <-- copy of image002.jpg image006.jpg <-- copy of image001.jpg The text in parentheses is not part of the file name. Why do I need it? I am creating video from a sequence of images and would like the video to play "forwards" and then