file-rename

Linux Rename file with only time/date stamp

落爺英雄遲暮 提交于 2019-12-23 13:38:07
问题 I have a single file which I want to rename mv to year_month_day_h:m:s - whats the best way to do that? I've tried the following but it doesn't dynamically add the correct stamp (original file actually has a backslash in the name): mv getnw/myfilename.txt "%Y%m%d%H%M%S".txt mv getnw/myfilename.txt "%Y-%m%d%H%M%S".txt mv getnw/myfilename.txt %Y-%m%d%H%M%S.txt mv getnw/myfilename.txt "'date +%Y%m%d%H%M%S'.txt" 回答1: mv myfile.txt `date +%Y_%m_%d_%H:%M:%S`.txt 回答2: mv myfile.txt myfile`date -Is`

Why doesn't File.renameTo(…) create sub-directories of destination?

落爺英雄遲暮 提交于 2019-12-23 12:35:08
问题 Why doesn't File.renameTo(...) create sub-directories contained in the destination file path? For instance, File source = new File(System.getProperty("user.dir") + "/src/MyFolder/MyZipFolder.zip"); File dest = new File(System.getProperty("user.dir") + "/src/MyOtherFolder/MyZipFolder.zip"); System.out.println(source.renameTo(dest)); Since MyOtherFolder does not exist, this will always return false . In order for this to work, I have to ensure that all sub-directories exist either by creating

rename() returns -1. How to know why rename fails?

故事扮演 提交于 2019-12-23 09:30:07
问题 I am using c++ stdio.h's int rename ( const char * oldname, const char * newname ); rename() function to rename a folder but occasionally it fails to rename the folder and returns -1. Is there any way to know why is rename() failing? any way to know this error explanation via any c++ function. 回答1: It should be possible to get the concrete error from errno.h #include <errno.h> #include <string.h> ... if(rename("old","new") == -1) { std::cout << "Error: " << strerror(errno) << std::endl; } The

Rename multiple files with regular expression

不想你离开。 提交于 2019-12-23 05:14:07
问题 I downloaded some files from internet. In the name field of those files each ' ' character is replaced by "%20" . I want to rename all of those but number of files is too high. So manual approach would be clumsy. I know from command line with regular expression this can be done but I am not very familiar with it. So little help is needed. Summary is, I want to rename all files in a directory by replacing all "%20" patterns with " " . How can I do it? Sample: 17%20Clipping.cpp --> 17 Clipping

File upload after rename the file in zend

旧街凉风 提交于 2019-12-23 01:12:29
问题 This is my form class Admin_Form_RoomtypeForm extends Zend_Form { public function init() { $name = new Zend_Form_Element_Text('name'); $name->setLabel('Name :'); $imagePath = '/home/dinuka/image'; $image = new Zend_Form_Element_File('image'); $image->setLabel('Image URL :'); $image->setDestination($imagePath); $image->addValidators(array(array('IsImage', false))); $submit = new Zend_Form_Element_Submit('submit'); $this->addElements(array($name, $image, $submit)); } } This is my controller

File upload after rename the file in zend

女生的网名这么多〃 提交于 2019-12-23 01:12:28
问题 This is my form class Admin_Form_RoomtypeForm extends Zend_Form { public function init() { $name = new Zend_Form_Element_Text('name'); $name->setLabel('Name :'); $imagePath = '/home/dinuka/image'; $image = new Zend_Form_Element_File('image'); $image->setLabel('Image URL :'); $image->setDestination($imagePath); $image->addValidators(array(array('IsImage', false))); $submit = new Zend_Form_Element_Submit('submit'); $this->addElements(array($name, $image, $submit)); } } This is my controller

How to move files in the FTP server

好久不见. 提交于 2019-12-22 19:46:12
问题 I want move files from a FTP server to another directory in the same server. I think the method that I have to use is Rename . Well, I can't continue because i don't know how. In put or get operations there are data stream but not here, that's my problem $ftprequest = [System.Net.FtpWebRequest]::create($Source) $ftprequest.Credentials = New-Object System.Net.NetworkCredential($user,$pass) $ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::Rename $ftpresponse = $ftprequest.GetResponse()

Rename file using regular expression

别等时光非礼了梦想. 提交于 2019-12-22 12:19:13
问题 What I want to do is rename all file in a particular folder, such that if a filename contains any digit in it, it is removed. say, if a filename is someFileName.someExtension it remains the same, but if a file is like this, 03 - Rocketman Elton John it should be renamed to Rocketman Elton John (I did the part to remove the - ), another example, if the filename is 15-Trey Songz - Unfortunate (Prod. by Noah 40 Shebib) it should be renamed to Trey Songz Unfortunate (Prod. by Noah Shebib) (again

Rename multiple files from command line [duplicate]

落爺英雄遲暮 提交于 2019-12-22 10:45:13
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Renaming lots of files in Linux according to a pattern I have multiple files in this format: file_1.pdf file_2.pdf ... file_100.pdf My question is how can I rename all files, that look like this: file_001.pdf file_002.pdf ... file_100.pdf I know you can rename multiple files with 'rename', but I don't know how to do this in this case. 回答1: You can do this using the Perl tool rename from the shell prompt. (There

file renaming problem?

痞子三分冷 提交于 2019-12-22 04:55:14
问题 Renaming a file in c#: File.Move(source,Destination); File.Delete(source); It execute successfully, how ever when i try to rename the file again, the system gives this exception: The process cannot access the file because it is being used by another process. i cant find that where is this in use? when i further debug the error it shows me the class name is in the process of w3wp.exe which is IIS. What should i do next? getting foreach (string folder in folder) { FileSystemItem item = new