Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 24, 2017 22:18:46 GMT
Is there some method for changing, for example, all the files in a folder that are prefixed with 'AA' to 'BB', without renaming files individually?
|
|
Mick
Member
Posts: 992
What I collect: Mostly covers and postmarks. Also miscellaneous paper ephemera.
|
Post by Mick on Jul 25, 2017 0:57:18 GMT
Is there some method for changing, for example, all the files in a folder that are prefixed with 'AA' to 'BB', without renaming files individually? Go to a command prompt. Change to the directory in which the files are located. Type command ren AA* BB*And there you have it.
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 1:07:25 GMT
Thank you Mick. I'll have a go at that in the morning. I'll report back as soon as I've made a pig's ear of it.
|
|
|
Post by PostmasterGS on Jul 25, 2017 1:10:08 GMT
|
|
angore
Member
Posts: 5,697
What I collect: WW, focus on British Empire
|
Post by angore on Jul 25, 2017 1:19:59 GMT
Wow! That is a lot of options.
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 1:20:17 GMT
Hi Mick,
I've worked out how to change the directory in the command prompt but the rename command (ren AA* BB* - the actual syntax I'm using is: ren HK_* HK *) results in a 'file not found' response.
I can't figure why this is, as there are loads of 'HK_' files.
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 2:53:46 GMT
Thank you P..GS, I've downloaded this, but will have to get my head round the syntax and which fields I need to use.
|
|
Ryan
Moderator
Calgary, Alberta, Canada
Posts: 2,749
What I collect: If I have a catalogue for it, I collect it. And I have many catalogues ....
|
Post by Ryan on Jul 25, 2017 3:13:19 GMT
Doing a batch file name change in the command prompt is easy ONLY if you're trying to keep the exact same number of characters in the file name. For example, your request to change all "AA"s to "BB"s would be easy because both "AA" and "BB" are the same length. If you were trying to change "AA" to "RENAMED" then that would make a mess of everything, changing all the "AA"s to "RE"s and then attempting to change the further 5 characters in each file name (whatever they might be) to "NAMED". So, let's assume that your desired change is in fact what you gave as an example and I'll show an example that's similar. First, to open the command prompt, click on the Windows logo in the lower left and you'll get a menu that opens similar to what I show here. In the box where it reads Search programs and files, type cmdand hit enter. This will run the command prompt program, CMD.EXE - the starting point will look similar to this.Now you need to figure out how to get to your target directory. You can always tell what directory you're in - it's shown immediately before your flashing cursor. In my case, I'm in the directory C:\Users\Ryan. Each piece of the directory listing is the equivalent to a folder inside a folder inside a folder (etc.) in Windows Explorer. You need to know where you want to go, of course, but it's just the equivalent of clicking on folders within Windows Explorer. First things first - make a directory listing so you can see the contents of your current directory. Type dirand hit enter ("dir" is an abbreviation for "directory", the command prompt equivalent of a folder). If you have a whole bunch of stuff in your directory, then your listing will be too long to fit on the screen and you'll probably miss a bunch of listings. If that's the case, you can improve your "dir" command like this - instead of the short "dir" command, I have typed dir | moreand after taking the above screen capture, I hit enter. That vertical line is called a pipe - on my keyboard, it's a capitalized backslash. It might be elsewhere on yours. This will give you just enough listings to fill one screen - hit the space bar each time you want to read another screen. Below is what my directory listing looks like. In this case, I want to go into the directory (the folder) named "Desktop". I have already typed cd Desktopand after taking the screen capture, I hit enter - "cd" is an abbreviation for "change directory". On my desktop, I know that I have a folder named "stamp scans" that holds a bunch of scanned images. But I want to make sure, so I'll do a directory listing again - I type dirand I hit enter. Lots of other stuff on my desktop, but you can see my desired target directory "stamp scans" listed in the screen above (directories always have "<DIR>" before them in these listings - files don't). Again, I need to use the "cd" command to go into that directory / folder. I have already typed cd stamp scansand after taking the screen capture, I hit enter to go into that directory. Then I typed dirand I hit enter to get a directory listing of my "stamp scans" directory / folder. Here's what the end of that listing looks like. You can steer your way through your directories (folders) using the "cd" command. If you ever find you've gone "down" too many levels and you need to go back "up", type cd ..and hit enter. The two periods are an old DOS shorthand command to go back up a directory level. In my example, I'm going to change all those .JPG files starting with "scan" to something that starts with "xxxx". Again, it's important to keep the replacement string length the same as the target string length. As I said, things can get messy otherwise! I have already typed ren scan* xxxx*and after taking the screen capture, I hit enter. The "ren" command is an abbreviation for "rename". The "*" is a wildcard which is shorthand for "every possible string of characters". This string can be any length when you use the "*" wildcard - using the "?" wildcard would match only strings with a length of one character, "??" would match only strings with a length of two characters, " " would match only strings that are 3 characters long, etc. After executing this rename command, I type dirto get a directory listing showing the new file names and it looks like this. You need to be careful not to accidentally mess up when you're working with these DOS commands. If you try renaming the ".." directory, or worse deleting it, who knows what disaster might befall you. My uncle the computer killer would regularly open up a wormhole to some alternate universe by typing in random stuff that he shouldn't have - he was continually dragging his computer back to the repair shop so they could fix whatever mess he had created .... Ryan
|
|
Ryan
Moderator
Calgary, Alberta, Canada
Posts: 2,749
What I collect: If I have a catalogue for it, I collect it. And I have many catalogues ....
|
Post by Ryan on Jul 25, 2017 3:21:35 GMT
the rename command (ren AA* BB* - the actual syntax I'm using is: ren HK_* HK *) results in a 'file not found' response. I can't figure why this is, as there are loads of 'HK_' files. The problem is probably the space between the HK and the *. In DOS syntax, that looks like two separate names when only one is expected. Try enclosing your file names in quotes to make the space explicitly included: ren "HK_*" "HK *"But before you do, copy some of the files into a working directory and mess around with the rename command on that working directory. Don't be like my uncle the computer killer and learn the hard lessons! ha ha (I tried it myself on my files named "thumb 0002" and "thumb 0005", and it worked fine without opening any wormholes so you ought to be fine, but it's best to be safe ....) Ryan
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 3:43:55 GMT
Thank you so much Ryan for the enormous effort. As you noticed I did manage to wobble through some of the command prompt commands (I've never done anything in my pc's bowels before). Your suggestion about the quotes is worth trying. It's a bit frustrating not knowing the syntax strings that are permissible, as the Help command is somewhat brief. I shall keep a copy of your screen shot 'opus', as there is a lot of useful stuff to learn. You never know, I might learn to use my beast properly. I've only owned pc's for about 18 years, so I'm a bit of a novice. Thanks again old bean.
|
|
Jerry B
Departed
Rest in Peace
Marietta, Georgia USA
Posts: 1,485
|
Post by Jerry B on Jul 25, 2017 9:27:07 GMT
Hi Ryan
Every time I use DOS I complain about typing the DIR for the CD command. After all these years of using DOS, accidentally I found out something I never knew.
Navigate to the folder you want to operate on. Once there, type CD at the DOS prompt, then on the directory, or folder, address bar, drag the folder icon to the space after the DOS CD command. Voila!!
Jerry B
|
|
Jerry B
Departed
Rest in Peace
Marietta, Georgia USA
Posts: 1,485
|
Post by Jerry B on Jul 25, 2017 9:38:38 GMT
Hi anping Take a look at this site: DOS Overview (Windows cmd)
Gives a little overview of the commands available. Once in DOS (running the Windows command cmd, type Help and you will get a list of the commands and parameters if any.. Jerry B
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 11:23:18 GMT
Jerry,
Thanks for that tip for pasting the folder into the 'cmd' line. It does seem to encase the drive/path/folder name in quotes though, which I removed. Perhaps it works with them but I find the process of working out the correct syntax tedious. It would be useful if one could copy and paste sections of commands previously input from within the actual 'Dos screen', instead of having to retype them.
Thanks too for the link, which is very useful.
Well I've had some success at testing the rename command. I created a new folder, as Ryan suggested, and put a few files in there. The rename worked for the string I wanted ("HK_" to "HK "). What does NOT work is this experimental rename of files with period within the start of a filename: ren "HK.*" "HK *". This results in the filename having a space inserted before the period, for example: HK.$1 becomes HK .$1.
There is no mention of this in the MS-Dos Command line overview (in the link).
Curious.
|
|
Ryan
Moderator
Calgary, Alberta, Canada
Posts: 2,749
What I collect: If I have a catalogue for it, I collect it. And I have many catalogues ....
|
Post by Ryan on Jul 25, 2017 11:46:08 GMT
In DOS, the only possible location for a period in the filename is to separate the file's name from its extension (the "extension" refers to the code for the type of file you're naming - .JPG for pictures, .TXT for text files, .XLS for Excel spreadsheets, etc etc). The original DOS standards don't allow for periods in the middle of filenames like we can have nowadays, so it's not such a surprise that your filename change doesn't work easily. I say easily, because there's most likely a way around it with further codes, but it probably takes longer to figure out the magic codes than it does to just change those files manually.
Ryan
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 11:58:52 GMT
The original DOS standards don't allow for periods in the middle of filenames like we can have nowadays, so it's not such a surprise that your filename change doesn't work easily. I say easily, because there's most likely a way around it with further codes, but it probably takes longer to figure out the magic codes than it does to just change those files manually. I suspected that the use of a period in the filename may have had something to do with it. I was actually just putting the rename command 'through its paces'. I don't have file names of that format, but I'd guess that some do, particularly as the use of the period in filenames was the norm in OS mainframe systems; e.g. BBL.TEMP.SORT.FILE1 etc.
|
|
Jerry B
Departed
Rest in Peace
Marietta, Georgia USA
Posts: 1,485
|
Post by Jerry B on Jul 25, 2017 12:16:42 GMT
Hi Anping Finally, another mainframe person DOS commands give one the ability to do "low level" operations. To do a task, the command(s) can start becoming complicated. To do a particular job repeatedly with DOS one can create a "Batch" file with the commands contained. Execute the Batch file and the commands within are executed. Jerry B
|
|
Anping
Departed
Rest in Peace
Posts: 533
What I collect: Hong Kong, Aden & States & odd stuff I like.
|
Post by Anping on Jul 25, 2017 16:57:08 GMT
To do a particular job repeatedly with DOS one can create a "Batch" file with the commands contained. Execute the Batch file and the commands within are executed. Somehow I think I should keep things as simple as possible just for the moment. I had read about these batch processes somewhere before; but thanks for the info. Anyway, Ryan has scared me off with the story about his uncle.
|
|
Jerry B
Departed
Rest in Peace
Marietta, Georgia USA
Posts: 1,485
|
Post by Jerry B on Jul 26, 2017 9:31:14 GMT
Hi Anping
Don't be scared off. It is not rocket science. Using DOS, one does have to be extra careful as you can really mess things up. Just go slow. In the 1950's and 1960,s IBM had nameplate blocks with THINK , in various languages, on them (I think I still have a couple of them). That's the key, don't just dive in, go slow.
The cardinal rule for changing anything on the computer is backup. If files, like the renaming, copy the files to another location. That way, if you screw up, you can always get back to the original. If you are going to change a setting, Notepad is your friend. Open Notepad and type in the current setting(s) that are to be changed, close Notepad and save the resulting file. Again, if you make a mistake, you can correct it.
The first time I edited the registry I was scared to death as one hears all the horror stories. But I backed up the current Registry before editing. I do some programming and prior to making updates I copy the code files. I purchased a 32G flash drive (stick) and after a programming session I back up the code to that.
As has Ryan, I have seen people totally screw up their computers. First, not thinking of the steps you are going to do and second no backup.
Jerry B
|
|