rename

Change file name suffix(es) (using sed ?)

独自空忆成欢 提交于 2019-12-12 12:04:29
问题 I'd like to change the file name suffix from files (using a bash script), but sometimes there are files with one period and some with two. Now I use this: new_file=`echo ${file} | sed 's/\(.*\.log.*\)'${suf}'/\1.'${num}'/'` Where 'new_file' is the new file name, 'file' the original file name, '${suf}' the file's suffix and ${num} a new number. So some.log must become some.log.1 and some.log.1 must become some.log.2 . With my code some.log becomes some.log.1 , but some.log.1 remains some.log.1

Add file extension to all files in a folder in R

送分小仙女□ 提交于 2019-12-12 10:57:36
问题 As a result from a loop I have a lot of files without a file extension in a folder. How could I add a file extension (.png) to all files in the folder while keeping the original name, e.g. from NAME1 to NAME1.png , NAME3 to NAME3.png , NAME6 to NAME6.png etc using R? 回答1: With the list.files function you can retrieve the file names under a given path and with a given pattern. From them you can use paste to add your file extension and next file.rename to rename the files. For instance:

Python program to rename file names while overwriting if there already is that file

ぃ、小莉子 提交于 2019-12-12 09:33:16
问题 As the title says, I wanted a python program that changes the file name, but I wanted to overwrite if there already is a file with that destination name. import os, sys original = sys.argv[1] output = sys.argv[2] os.rename(original, output) But my code just shows me this error when there already is file with that destination name. os.rename<original, output> WindowsError: [Error 183] Cannot create a file when that file already exists What fix should I make? 回答1: On Windows os.rename won't

Remove hyphens from filename with Bash

江枫思渺然 提交于 2019-12-12 09:24:50
问题 I am trying to create a small Bash script to remove hyphens from a filename. For example, I want to rename: CropDamageVO-041412.mpg to CropDamageVO041412.mpg I'm new to Bash, so be gentle :] Thank you for any help 回答1: Try this: for file in $(find dirWithDashedFiles -type f -iname '*-*'); do mv $file ${file//-/} done That's assuming that your directories don't have dashes in the name. That would break this. The ${varname//regex/replacementText} syntax is explained here. Just search for

Rename “None” value in Pandas

坚强是说给别人听的谎言 提交于 2019-12-12 08:41:59
问题 This is probably super simple but I just can not find the answer. I import data using GeoPandas from a shape file. Turn that into pandas DataFrame . I have a object field with three letter codes and None values for missing data. How do I change None 's to something like "vcv" in pandas? I tried this sala.replace(None,"vcv") got this error 2400 "strings or regular expressions, you " 2401 "passed a" -> 2402 " {0!r}".format(type(regex).__name__)) 2403 return self.replace(regex, value, inplace

Ressources not found | ANT Rename application package

[亡魂溺海] 提交于 2019-12-12 08:15:32
问题 After lots of digging i found the solution how i can rename my application package. It's working great. There are two different ways. The one via arg params: <!-- Replaces the target in tools\ant\build.xml --> <target name="-package-resources" depends="-crunch"> <!-- this exec replicates the output of the aapt task in build.xml -package-resources with the addition of a rename-manifest-package option. --> <exec executable="${aapt}" failonerror="true"> <arg value="package" /> <arg value="-f" />

How do I rename a column in a database table using SQL?

我与影子孤独终老i 提交于 2019-12-12 07:06:32
问题 If I wish to simply rename a column (not change its type or constraints, just its name) in an SQL database using SQL, how do I do that? Or is it not possible? This is for any database claiming to support SQL, I'm simply looking for an SQL-specific query that will work regardless of actual database implementation. 回答1: On PostgreSQL (and many other RDBMS), you can do it with regular ALTER TABLE statement: => SELECT * FROM Test1; id | foo | bar ----+-----+----- 2 | 1 | 2 => ALTER TABLE Test1

Rename folders in c# Form

て烟熏妆下的殇ゞ 提交于 2019-12-12 05:59:22
问题 i try to make a Form program in c# to rename a lot of folders. The Customers has to choose the folder (and the name to rename), where all the folders are include, for example in c:\folders\ are this folders: 1991 - title1 1992 - title2 1993 - title3 1994 - title4 And now i will change the year into a name, like this: name - title1 name - title2 name - title3 name - title4 Example pic: I hope you unterstand what i want :-) and you can help me with this. Regards, matthias 回答1: A few hints: Get

Batch file to detect only part of a filename

99封情书 提交于 2019-12-12 05:37:10
问题 I need a snippet of a batch file that can detect part of a filename, then rename it. Note that the numbers after the filename change randomly but "file" is always the same. Example: filename: file143424 There will always be only one file that needs to be renamed in the folder. The script will delete older versions of the file. For instance, I put a first file inside the folder and the script in there too. I then run the script, which renames it to just file. Then if I put a new file in, the

Fetching a result twice with deferend name

怎甘沉沦 提交于 2019-12-12 05:25:02
问题 I have 1 table with tasks named opentask: columns: id,title,description,expires,creator_id,creator_name, executer_id, executer_name, priority_id, status_id 1 table with users named user: with columns: user_id, username What I want is to create a query where there will be all columns from opentask table where the executer_id will be equal to the user_id of user table AND the creator_id will be equal to the user_id again. This creates a confusion because the first equality excludes the second.