renaming mass files from o to xxxx - bash

I would like to rename multiple folders of files from
Blackmagic Cinema Camera_1_2013-12-06_2248_C0001_000000.dng
…
Blackmagic Cinema Camera_1_2013-12-06_2248_C0001_000322.dng
to
0.dng
…
322.dng
So in fact from 0 to xxxx (for safety get to 5 digits if necessary)
I am really new to the terminal tool (on mac osx 10.8) and cannot do the dumbest thing with it, I just know it's the most reliable way to do it, and as they are quite precious files for a project I'm not that keen on using a regular rename application that may do I don't know what slightly more than just rename those files, I just want them to be as pure as they are with the names changed.
So I read many stuff on here but as I know absolutely nothing about any command I can't interpret what was listed on the numerous topics on how to rename as they don't exactly apply to what I want to do. So if you could guys explain to me things as dumb as I am for it to be simple and comprehensible (what has to be explained, actually I just want something to work, not a class), would be great. This forum seems to have good answers quickly, seems all nice
Ah, btw, I would actually run that for a single file first (as a try) and after use it for all the folders of these like-named files. So it's like
Blackmagic Cinema Camera_1_2013-12-06_2321_C0005
…
Blackmagic Cinema Camera_1_2013-12-06_2327_C0000
for the folders names, each one containing a pile of files named like stated in the first part of this message. so i guess it would need something to apply to all folders of a chosen folder, as there are numerous ones.
(ah, when I say i'm the dumbest guy about it : I can understand, but just have no clue on this stuff, so if you could even tell me how to get to that file/folder/directory etc. whatever be needed to complete it for someone knowing 0)
Thanks in advance, very much !

From the directory containing your DNG files:
awk -F"[_.]" '$(NF) ~ /dng/ {system("mv "$0" "($(NF-1)+0)".dng");}' <(find .)
It worked for me in linux, and it should work in mac os too.
If you have any problem, just leave me a comment ;-)

Related

Need help understanding a move script written for CMD involving multiple subdirectories into one directory

I got a folder with a lot of images in it, and I'd like to move everything to the main folder so basically I would like to turn this:
L:\Pixiv\Tags\44324\Image1.jpg
L:\Pixiv\Tags\4564356\Image2.jpg
L:\Pixiv\Tags\325423\Image3.jpg
L:\Pixiv\Tags\16324\Image4.jpg
...into this
L:\Pixiv\Tags\Image1.jpg
L:\Pixiv\Tags\Image2.jpg
L:\Pixiv\Tags\Image3.jpg
L:\Pixiv\Tags\Image4.jpg
I did some looking, and I discovered a move function for CMD, and while most of it I can understand, some of it I can't, and frankly, I'm just that smart enough to know what happens when you start playing around with stuff you don't fully understand, so I don't do it. Point is your basic move function is basically something like "move c:\Whatever C:\Whocares," but as you can tell from below, this is a little more complicated.
for /r %d in (*) do move "%d" "d:\all snaps\"
/r I think goes through all the folders at the current target directory. So if I'm in L:\Pixiv\Artists and I type in this code for L:\Pixiv\Artists as a destination folder every file in Artists is going to be dumped into Tags. Is this correct?
%d I couldn't make sense out of, so I've no idea what it does. Also, for ease of use, I would like to put this in a batch script, because boy howdy, do I got a lot of folders that needs to be fixed. From what little I was able to read I should write the same as above, but change %d to %dd, correct? Also where at would I add a target directory, so I could just write a batch script, and be done with it? Also, apologies in advance for my lack of knowledge, usually I use Batchrun when it comes to automating stuff.

Possible to copy/move/etc multiple files of same base name via Windows CMD/.BAT?

I am wondering if it is possible to accomplish the following, given some context and example.
I have files in "Server\Share\Folder\File##.ext"
Sometimes the "File##.ext" can be "File01.ext" through "File20.ext", and other times it may be "File01.ext" through "File40.ext"
Sometimes there are less of these files, sometimes there are more.
I want a batch file to take the files from "Server\Share\Folder\File##.ext" and move them to "Server\Share\OtherFolder\File##.ext". I know I can accomplish this easily with:
copy /y "Server\Share\Folder\File01.ext" "Server\Share\OtherFolder\File01.ext"
Then just add another line for each extra "File02.ext, File03.ext, etc., but I am wondering if it is possible to make it so that any file that resembles "File##.ext" can be included, so that no matter how many ## I have, it always works without issue.
Thanks in advance for any and all advice!
EDIT
Someone mentioned using Wildcards, but my question with that is - lets say those files are File01.ext through File05.ext, will it match what it finds to the newly moved file? Like will it find File01 from File?? on the source and Make it File01 from File?? at the destination?
You can accomplish this task with a FORloop program in batch-file.
You can also loop through the Commands using : and variable name.
Combining these two would help you get what you want.
We can help you with Ideas and little bit of the coding. But the Efforts must be done by you. So U can learn programming better

How to use the "Project Drawer" in TextMate 2 when it doesn't seem to exist?

On TextMate 2 and opening two files in two different locations such as /path/1/file.txt and /path/2/file.txt, I am no longer seeing a way to perform diffs as before since one cannot select files in the project "drawer." We now have a file browser that seems to have taken its place and thus no way to pick the two opposing files. This also precludes any other command that requires multi file selection that are not within the file structure.
Am I missing something that would allow this to work properly when dealing with files in two different paths?
This isn't a new trick. It's one we learned when grep in project would go insane when you had a project with files whose common ancestor was root or some directory far above the files. Instead of opening your files like:
mate /foo/bar/baz /quix/quacks/quux
You do the following, assuming you're in an empty directory or don't care that its files will be included in the project as well
ln /foo/bar/baz /quix/quacks/quux . && mate .
That can obviously be wrapped up into a function to reduce the syntactical difference. In fact, at one point, I actually wrote a wrapper script around mate to do that transparently when needed AND clean up the hard linked files after I closed the project or quit TextMate. That went away with some bad hard drive though.
Anyhow I HTH

Programmatically hiding many files when creating hybrid iso with hdiutil

I'm trying to script the creation of a hyrbid (iso/joliet/hfs) iso with hdiutil. I can, for example, build an iso that hides things on the mac side like so:
hdiutil makehybrid -o foo.iso -hfs -joliet -iso -hide-hfs "{foo/bar.txt,foo/other.rtf}" foo
That's just an example of course, but the point is I can get it to hide say seven or eight example files I specify like that, with spaces in the filenames and verious dots and underscores.
But for my actual real-deal script I need to list in the neighborhood of 70 files, which does not seem to work when I test it. The whole string is being passed in correctly, I know this because when you turn on '-verbose' it prints the string and says it doesn't match anything.
So my best guess is it has something to do with the length of the string passed in, but I don't see anything in the docs indicating that. Any ideas? Think it's a bug? An alternative way of accomplishing this?
This is on Mac OS X 10.5.8, btw.
Two [UPDATE, make it Three] (untested) suggestions:
use the -plistin option to
specify all the parameters;
(better) try organizing the files to be
hidden into directories, if
necessary, so you can easily hide
them by directory-specific globs
rather than having to spell out each
file.
[UPDATE] you could try using mkisofs from cdrtools to make the ISO image. MacPorts has a supported port of it. It could be that the code in hdiutil was originally based on an earlier version. In any case, you have the advantage of access to the source code and perhaps figuring out what the limitations are.
P.S. There seems to be a couple of minor nits with the MacPorts port. In particular, the
man pages are installed in the wrong directory. [UPDATE: fixed in 3.00_1]

Identifying CDs

I'd like to be able to determine what music album CD is in a CD drive. For example, if someone claims that the CD in their drive is Eminem - The Eminem Show, I would like to be able to verify that the CD is indeed The Eminem Show.
Any ideas? I've applied for a Gracenote developer license, but they won't get back to me for five days.
Also, how does this work? Is there some GUID or other unique identifier that music discs are encoded with?
Lastly, might this be possible with data CDs, like, say, the Diablo II install Disc 1? If so, any directions you can point me in, for accomplishing this?
You may want to look a the Wikipedia article to learn how CDDB work. Then you can look at libcddb to implement what you want in C. The source code should give you plenty of clues in case C is not your language of choice.
You probably want to use something like libcddb to get/verify music CD information. I don't know if there is a similar database for program discs.
As for music CDs, Gracenote works by analyzing the actual waveform data of every track on the CD. It does this is a format-neutral way. It talks about it here.
I'd also recommend last.fm, MusicBrainz, and discogs.

Resources