file-rename

File extension renaming in R

耗尽温柔 提交于 2020-05-15 11:12:37
问题 I am just trying to change the filename extensions to .doc. I'm trying the code below but it does not work. How come? I'm using instructions from here startingDir<-"C:/Data/SCRIPTS/R/TextMining/myData" filez<-list.files(startingDir) sapply(filez,FUN=function(eachPath){ file.rename(from=eachPath,to=sub(pattern =".LOG",replacement=".DOC",eachPath)) }) The output I get is: DD17-01.LOG DD17-02.LOG DD17-03.LOG DD17-4.LOG DD17-5.LOG DD37-01.LOG DD37-02.LOG DD39-01.LOG DD39-02.LOG DD39-03.LOG FALSE

File extension renaming in R

拈花ヽ惹草 提交于 2020-05-15 11:10:51
问题 I am just trying to change the filename extensions to .doc. I'm trying the code below but it does not work. How come? I'm using instructions from here startingDir<-"C:/Data/SCRIPTS/R/TextMining/myData" filez<-list.files(startingDir) sapply(filez,FUN=function(eachPath){ file.rename(from=eachPath,to=sub(pattern =".LOG",replacement=".DOC",eachPath)) }) The output I get is: DD17-01.LOG DD17-02.LOG DD17-03.LOG DD17-4.LOG DD17-5.LOG DD37-01.LOG DD37-02.LOG DD39-01.LOG DD39-02.LOG DD39-03.LOG FALSE

File extension renaming in R

蓝咒 提交于 2020-05-15 11:10:10
问题 I am just trying to change the filename extensions to .doc. I'm trying the code below but it does not work. How come? I'm using instructions from here startingDir<-"C:/Data/SCRIPTS/R/TextMining/myData" filez<-list.files(startingDir) sapply(filez,FUN=function(eachPath){ file.rename(from=eachPath,to=sub(pattern =".LOG",replacement=".DOC",eachPath)) }) The output I get is: DD17-01.LOG DD17-02.LOG DD17-03.LOG DD17-4.LOG DD17-5.LOG DD37-01.LOG DD37-02.LOG DD39-01.LOG DD39-02.LOG DD39-03.LOG FALSE

How to find and replace part of filenames from list

最后都变了- 提交于 2020-04-16 05:48:09
问题 I have a list of files that I need to rename at the same part of each file, with different values. Example: BL_1402B103_abc.wav > BL_C1234-1_abc.wav BL_15489B59_abc.wav > BL_C1234-5_abc.wav So in the first example above I want to replace the 1402B103 with C1234-1 all the files are the same length and the sections I want to replace are separated by " _ ". I have some code for finding/replacing parts of a filename but I need to do this for hundreds of files - is there a way to pull Pattern= &

Copy and rename Specific Files based on parent directories in R

早过忘川 提交于 2020-02-06 08:46:31
问题 I am attempting to solve this issue in R, but I'll upvote answers in any programming language. I have an example vector of filenames like so called file_list c("D:/example/sub1/session1/OD/CD/text.txt", "D:/example/sub2/session1/OD/CD/text.txt", "D:/example/sub3/session1/OD/CD/text.txt") What I'm trying to do is move and rename the text files to be based on the part of the parent directory that contains the part about sub and session . So the first file would be renamed sub2_session1_text.txt

Giving uploaded images a unique name for mysqli

故事扮演 提交于 2020-02-04 04:37:25
问题 I want to allow users to upload images without conflicting problems that may be caused by multiple users uploading images that potentially have the same image name. I am stumped on how to execute this and I have no idea where to start.. Here is my code: if(isset($_POST['submitimage'])){ move_uploaded_file($_FILES['file']['tmp_name'],"pictures/".$_FILES['file']['name']); $con = mysqli_connect("localhost","root","","database"); $q = mysqli_query($con,"UPDATE users SET image = '".$_FILES['file']

how to change a part in multiple filenames from 1 to 01?

空扰寡人 提交于 2020-01-25 12:47:27
问题 I have lots of files in a directory. Example: "/data/2014/file300.data.20141231.MC.9.vgf.img" here 9 represent the hour and change from 1 to 24 ,the date also change. the hours are represented .1. .2. .3. .4. .... .9. I want to replace this part(only this part) in the file name with .01. .02. .03. .04. .... .09. and do not touch any other number in the file name. so .1. become .01. and so on 回答1: Try this with Larry Wall's rename to replace .MC. by .MC.0 : rename 's/\.MC\./.MC.0/' /data/2014/

Batch file renaming: How to preserve the order of filename?

∥☆過路亽.° 提交于 2020-01-24 21:59:24
问题 I have 1000 images that I want to rename them from 1 to 1000. I found this solution (the most voted answer): dirData = dir('*.png'); %# Get the selected file data fileNames = {dirData.name}; %# Create a cell array of file names for iFile = 1:numel(fileNames) %# Loop over the file names newName = sprintf('%04d.png',iFile); %# Make the new name movefile(fileNames{iFile},newName); %# Rename the file end But it falls short when the number of digits from the original file name changes.

Prevent a user from deleting, moving or renaming a file

烈酒焚心 提交于 2020-01-21 04:16:28
问题 What I am trying to do is while my program is using a file, I want to keep the user from renaming, deleting, or moving the file (well... a move is a delete and a create at a different location according to Windows FileSystemWatcher, but I digress). It has been suggested that I use FileStream.Lock or use a Mutex. However, FileStream.Lock seems only to prevent the file from being modified which I am trying to allow . Also, I am very unsure as to if a mutex can lock a file, although I am still

Renaming a folder name which has sub directories is not working using java File.rename.to()

一世执手 提交于 2020-01-06 06:40:31
问题 My folder structure is D: root popcorn-folder <--- renaming doesnt work popcorn-subfolder <--- renaming doesnt work popcorn-file <--- renaming doesnt work popcorn-folder2 <- renaming works popcorn-file1 <--- renaming work The code is public static void renameDirectory(File base) throws IOException{ //LinkedList<File> fileList = new LinkedList<File>(); int count=0;//count the renamed files in this directory + its sub. You wanted to do this? //Process each file in this folder. for (File file: