rename

rename() only works for directory that program is running in?

核能气质少年 提交于 2020-01-07 05:12:11
问题 I am trying to rename a bunch of files in a user specified directory, but it only seems to be working when the user specifies the directory that the program is running from. For example, when running from the command line: ./a.out . "NewName.txt" will work, while ./a.out .. "NewName.txt" will not work. Is there a reason for this? It's on Linux, by the way. int main(int argc, char** argv){ char* dirpath = argv[1]; char* newName = argv[2]; DIR *d; struct dirent *dir; d = opendir(dirpath); if (d

Batch Renaming Folders in AppleScript, Will Only Change Names of Every Other Folder

时光毁灭记忆、已成空白 提交于 2020-01-06 15:02:14
问题 I am trying to write a script that renames folders in subfolders. In other words, the taxonomy will go from: Directory/Company X/1 Directory/Company X/2 Directory/Company X/3 Directory/Company X/4 Directory/Company X/5 Directory/Company X/6 Directory/Company X/7 Directory/Company X/8 Directory/Company X/9 Directory/Company X/10 Directory/Company X/info to Directory/Company X/Project 1_1 Directory/Company X/Project 2_2 Directory/Company X/Project 3_3 etc.. So far I have: tell application

Rename Mysql Table name with concat

老子叫甜甜 提交于 2020-01-06 14:07:37
问题 In MySQL, I need to rename a table with a suffix which identifies previous month, and I'm trying to do that with this syntax: RENAME TABLE 'myTable' TO CONCAT('myTable',DATE_FORMAT(CURRENT_DATE - INTERVAL 1 MONTH, '%Y_%m')); F.e: I've table name "customers" and what I want is "customer_2015_04". The problem is with concat order. What am I doing wrong? Best regards, 回答1: I think you need to do this using a prepared statement: set @sql = CONCAT('RENAME TABLE myTable TO myTable', DATE_FORMAT

OCaml: Why does renaming a type fail with “Their kinds differ”

依然范特西╮ 提交于 2020-01-05 01:12:21
问题 I'm building an universal container for for pairs of a type witness and a value of the witnessed type. This I want to use for several different types, which gives me errors because the types are all named the same. So I'm trying to rename types in the result of a functor like this: module type Witness = sig type 'a key type 'a value end module type Witnessed = sig type 'a key type 'a value type t type ('a, 'b) conv = { key : 'c . 'c key -> 'a; value : 'c . 'c value -> 'b; } val box : 'a key -

Windows Powershell - Rename a list of files using a list from a text document

点点圈 提交于 2020-01-05 01:09:29
问题 I tried using the following code to rename a folder of files "C:\www\folderx" using a text list "..\list.txt" , but I can't figure out how to get the current file index: Get-Childitem C:\www\folderx | % { $OldName = $_.name; $NewName = (GC ..\list.txt)[<CURRENT INDEX SHOULD GO HERE>]; # Rename-Item -Newname $NewName; Write-Output $("Renamed {0} to {1}" -f $OldName,$NewName); } 来源: https://stackoverflow.com/questions/17256501/windows-powershell-rename-a-list-of-files-using-a-list-from-a-text

Adding extension to multiple files (Python3.5)

我只是一个虾纸丫 提交于 2020-01-04 09:22:08
问题 I have a bunch of files that do not have an extension to them. file needs to be file.txt I have tried different methods (didn't try the complicated ones since I am just learning to do a bit of advanced python). here is one that I tried: import os pth = 'B:\\etc' os.chdir(pth) for files in os.listdir('.'): changeName = 'files{ext}'.format(ext='.txt') I tried the append, replace and rename methods as well and it didn't work for me. or those don't work in the 1st place with what I am trying to

Change HTML name element using JavaScript

六眼飞鱼酱① 提交于 2020-01-03 17:00:41
问题 On the press of a div (which I made into a button with other code) I would like the following code: <div id="w1" name='w1-0' onclick="weekclick(id)">1<br /></div> ...for the name to change from name='w1-0' to name='w1-1' I'm using the following JavaScript: function weekclick(id) { document.getElementById(id).input.name = "w1-1"; } When I alert the id's name, it says it is undefined. What do? 回答1: see code below: <div id="w1" name='w1-0' onclick="weekclick(id)">1<br /></div> <div onclick=

python program to rename the file with current date in MMDDYYY format and send email with attachment [duplicate]

て烟熏妆下的殇ゞ 提交于 2020-01-03 06:40:11
问题 This question already has answers here : How to rename a file using Python (10 answers) Closed 2 years ago . Below is the program to send email with attachment: I want to rename the file student.xlsx to student_MMDDYYYY.xlsx and send email with renamed file and after email is sent I want to delete that file. How can I do that? Here is my code: import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email

Perl's rename - how to append a counter?

偶尔善良 提交于 2020-01-03 02:33:06
问题 There's a nice renaming utility, which comes with Perl's installation. How one would append a counter in the Perl regexp? This is a relevant question e.g. for a problem of numbering files in the current directory: rename 's/^/<here I'd like to have a number of a file being processed>/g' * For example how would one rename: fileA fileB fileC to 1 - fileA 2 - fileB 3 - fileC Edit : I've added the counter feature ( $c variable) - see here. It works fine - but when I try to specify the counter

Loop rename variables in R with assign()

柔情痞子 提交于 2020-01-02 07:24:22
问题 I am trying to rename a variable over several data frames, but assign wont work. Here is the code I am trying assign(colnames(eval(as.name(DataFrameX)))[[3]], "<- NewName") # The idea is, go through every dataset, and change the name of column 3 to # "NewName" in all of them This won't return any error (All other versions I could think of returned some kind of error), but it doesn't change the variable name either. I am using a loop to create several data frames and different variables within