file-rename

Removing last n characters from Unix Filename before the extension

北慕城南 提交于 2019-12-11 23:04:33
问题 I have a bunch of files in Unix Directory : test_XXXXX.txt best_YYY.txt nest_ZZZZZZZZZ.txt I need to rename these files as test.txt best.txt nest.txt I am using Ksh on AIX .Please let me know how i can accomplish the above using a Single command . Thanks, 回答1: In this case, it seems you have an _ to start every section you want to remove. If that's the case, then this ought to work: for f in *.txt do g="${f%%_*}.txt" echo mv "${f}" "${g}" done Remove the echo if the output seems correct, or

Renaming test results of UITestActionLog files or folders as the test case name

天大地大妈咪最大 提交于 2019-12-11 22:02:43
问题 Really appreciate your help Adrian. I was able to add the .settingfile, how can I change the generated folder name as the testcase name , lets say I have my testcase as test1(){} I want the result folder to be named as test1 as well? I Select the option on the general tab and define the User_defined Scheme , but what ever I write there appears on my test result folder, I want it to be the name of my test case In coded UI, we need to rename the test result UITestActionLog files or folders to

command line batch remove _ from its file name

陌路散爱 提交于 2019-12-11 20:07:23
问题 I have multiple files and would like to rename its file. For example, I have "2014_19_24_english_test.doc" and to change it to "2014 19 24 english test.doc" Here is what I have done so far: for /f "delims=" %%f in ('dir /b *.hwp') do ren "%%~f" "%%~nf:_= %%~xf" and this is not working. Any help would be appreciated, Chris 回答1: You cannot use the substring replacement syntax with for variables, so you need an interim variable to do that, using delayed expansion: setlocal EnableDelayedExpansion

How to rename a file name named “.” [closed]

孤人 提交于 2019-12-11 19:49:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have downloaded a large file about 2gigs from remote server but by mistake I gave it name . (dot). How can I rename it using linux commands ? 回答1: I don't think you really have named it . . Or at least, you cannot have done so successfully. The name . is reserved for the current directory. So either it has

Android store recorded audio using input text?

亡梦爱人 提交于 2019-12-11 18:37:09
问题 I have an app that records and stores the audio on the sdcard. It records and saves it in the right place, but saves it as android.widget.EditText@random number. I was using an EditText to get the filename. Does anyone know how I can let the user enter some text and save the file as that. I thought I was onto something with the code below, but no... try { //Set user input as filename String filename = getInput.toString(); // set the storage directory to SDcard File storageDir = new File

Rename .txt files to first line in file?

旧城冷巷雨未停 提交于 2019-12-11 15:36:28
问题 I've got a lot of .txt files with names starting with "read" that I want to rename. I want them to be named with the first line in the file. I'm a really lousy programmer, but I've given it a go and now I'm stuck. import os for filename in os.listdir("."): if filename.startswith("read"): for line in filename: os.rename(filename, line) At the moment the script does nothing and even if it worked I'm pretty sure the files wouldn't keep their extensions. Any help would be greatly appreciated,

Script to change basename with without changing extension in linux

这一生的挚爱 提交于 2019-12-11 15:35:37
问题 I have several files with a.dat , a.txt , a.mp3 , b.dat , b.txt , b.mp3 , b.zip , b.rar , c.mp3 and so on. I want to rename all files with basename "a" to basename "x". Such that files become x.dat , x.txt , x.mp3 , b.dat, b.txt , b.mp3 , b.zip , b.rar , c.mp3` and so on. In Linux this can be done via terminal but requires lot of typing. I want a script to do the task for me. 回答1: I ll suggest a way, I think this could work. This is a little weird way I think, don't laugh. 10th std math.

Adding 2nd file extension to file with certain prefix

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 15:34:33
问题 I have following files in bulk to modify xxx.001 , xxx.002 etc. by adding .txt at the end of the file name. In order to do this I am using following command: rename XXXX*.* *?.txt However it inserts .txt twice instead of once. 回答1: A solution is renaming the files matching a wildcard pattern using a FOR loop. for %%I in (xxx*) do ren "%%I" "%%I.txt" This FOR loop in a batch file searches in current directory for non-hidden files of which file name matches the wildcard pattern xxx* . Each file

Renaming an upload file and display it

风流意气都作罢 提交于 2019-12-11 12:12:55
问题 every book and article that i've read recommend that we should rename upload file for security purpose. let say i have a code like this: if (!isset($error)) { $file = $_FILES['images']; $real_pic_name = $_FILES['images']['name'];; // Create a tmp_name for the file: $tmp_name = sha1($file['name']) . uniqid('',true); // Move the file to its proper folder but add _tmp, just in case: $dest = PDFS_DIR . $tmp_name . '_tmp'; if (move_uploaded_file($file['tmp_name'], $dest)) { //insert into database

Rename and move files in batch-dos

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:39:27
问题 I want to rename files and transfer them into a library using a batch file in the following way: c:\jg_Folder_xy> blabla01_000.bla --> blabla01_001.bla blabla02_000.bla --> blabla02_001.bla blabla03_000.bla --> blabla03_001.bla c:\sj_Folder_mx> blabla01_000.bla --> blabla01_002.bla blabla02_000.bla --> blabla02_002.bla blabla03_000.bla --> blabla03_002.bla c:\an_Folder_kj> blabla01_000.bla --> blabla01_003.bla blabla02_000.bla --> blabla02_003.bla blabla03_000.bla --> blabla03_003.bla and