Create a batch script to automatically unzip music and create directory to put it in - powershell

I want to create a script that automatically unzips music albums and creates a new directory for them on Windows 7.
I'd also want the script to compare file metadata to data pulled from a certain music site to ensure the ID3 tags are filled with accurate data.
Would something like Powershell be sufficient? I'd just love a finger pointed in the right direction.

DotNetZip will allow you to do this from PowerShell. It is not a one-liner, but the library will allow you to write the PowerShell script you need.
Tag lib wille allow you to play with ID3Tag. Example :
[Reflection.Assembly]::LoadFrom( (Resolve-Path ".\taglib-sharp.dll") )
$media = [TagLib.File]::Create("C:\Users\Joel\Music\Audity\The Language I Think In-Music of My Heart.ogg")
# Write out the current album name
$media.Tag.Album
# Set the album name to the name of the directory
$media.Tag.Album = ([IO.FileInfo]$media.Name).Directory.Name
# Save the new album name into the file
$media.Save()

You could download 7zip for your unzipping purposes.
The following command can be used to unzip the album:
7z.exe x -oOutputDir AlbumArchive(.zip, .rar, .7z, etc)
I'm not too familiar with the ID3 checkers and whatnot, so I'll defer to another for that part of your question.

Related

Create a file listing that contains the created date of the file

I'm trying to copy photos from someone's iphone to my windows laptop. The problem is the photos on the iphone save as filename like IMG 360, IMG 361 etc... but this isn't helpful when I want to copy these and organise by a certain filename and date created.
I use Google Photos and my own backup to organise photos in chronological order.
We went on holiday together and I am trying to find the best way to get their files organised and merged in with my own photos so that they appear in the right chronological order.
Unless there is a better way to do this, I am trying to create a file listing using a BAT file to list all the files together with their CREATED DATE and then I will create another BAT file to rename those files by incorporating their CREATED DATE.
Any ideas?
Thanks Chirag
I tried the below but this is supposed to only organise in chronological order, but it doesn't seem to even do that.
dir /a /b /-p /s /T:C /o:gen >filelisting.txt
You can use the command dir /T:C /O:D > filelisting.txt to create a file listing that contains the created date of each file in a directory.

How to move files whose file name is not used in a set of text files?

I'm a Powershell beginner and this is my first post on stackoverflow. I can understand some simple pipelines, but the following challenge is too complicated for me at this point:
I have a folder with testdata containing *.bmp files and their associated files. I want a powershell script to check which bmp-files are still used. If not used, move bmp-files and associated files to another folder.
Details:
bmp-files and associated files: For example; car01.bmp, car01.log, car01.file, car02.bmp, (...)
The bmp-files are in use if their file name (eg, car01.bmp) is mentioned in any of the (text/csv) files in at least one of 2 locations (incl. subfolders).
If the file name is not found in any of the text files, I want the script to move that file, and any file who's name differs only by file extension to a designated folder.
Looking forward to your solutions!

delete files with numbered names in matlab directory

I'm new to matlab and I've wrote a code that implements the gamma function for image processing. I generate around 300 photos named '001.jpg' to '300.jpg' and then use ffmpeg to make a video.
In the end, I only need the video result and need a command to delete all the photos generated in the directory! is there a way to do that?
If you want to remove all .jpg files in the current directory you can use the delete command with a wildcard (*)
delete('*.jpg')
If the files live in a folder other than the current directory, you can specify the directory in this way.
folder = '/path/to/my/files';
delete(fullfile(folder, '*.jpg'))
If you want to limit it to just files that have number filenames, you could do something like the following
files = dir('*.jpg');
filenames = regexp({files.name}, '^[0-9]+\.jpg$', 'match', 'once');
filenames = cellstr(cat(1, filenames{:}));
delete(filenames{:})
Adding to Suever's answer (not allowed to comment yet):
Assuming you already know the names of the images you're creating, you could save your script a 'trip' to the folder and back by creating the filenames list yourself thus:
for i=1:numOfImages
filenames(i)={strcat(num2str(i),'.jpg')};
end
delete(filenames{:})

How do you trim the XMP XML contained within a jpg

Through the use of sanselan I've found that the root cause of iPhone photos imported to windows becoming uneditable is that there is content (white space?) after the actual XML (for more details and a linked example of the bad XMP XML see https://apple.stackexchange.com/questions/45326/why-can-i-not-edit-some-photos-imported-from-an-iphone-to-windows-vista).
I'd like to scan through my photo archive and 'trim' the XMP XML.
Is there an easy way to do this?
I have some java code that can recursively navigate my photo archive and DETECT the issue. I'm not sure how to trim and write the XML back though.
Obtain the existing XML using any means.
The following works if using the Apache Sanselan library:
String xmpXml = Sanselan.getXmpXml(new File('/path/to/jpeg'));
Then trim it...
xmpXml = xmpXml.trim();
Then write it back to the file using the solution to serializing Xmp XML to an existing jpeg.
try the following steps:
collect all of the photos in a single folder (e.g. folder xmlToConvert on your Desktop)
open a Terminal.app window
cd to the directory you put the files in (e.g. cd ~/Desktop/xmlToConvert)
run the following command from your command line prompt
mkdir converted ; for f in *.xml ; do cat $f | head -n $(wc -l $f) > converted/$f ; done
the converted/ sub-directory should now contain all the files without the whitespace at the end.
(i.e. a folder called converted in the xmlToConvert you created on your Desktop)
hth

C# folder and subfolder

Upon numerous searches, I am here to see if someone has any idea on how I should go about tackling this issue.
I have a folder with sub-folders. The sub-folder containers each has files of different file types e.g. pdf, png, jpeg, tiff, avi and word documents.
My goal is to write a code in C# that will go into the subfolder, and combined all the files into one pdf using the name of the folder. The only exception is that a file such as avi will not be pdf'ed in which case I want a nudge as to which folder it is and possibly file name. I am trying to use the form approach, so that you can copy in the folder pathname and also destination of the created pdf.
Thanks.
to start, create a FolderBrowserDialog to get the root folder. Alternatively just make a textbox in which you paste the folder name ( less preferred since the first method gives you nicer error-handling straight out of the box )
In order to iterate through, see How to: Iterate Through a Directory Tree
To find the filetype, check System.IO.FileInfo.Extension for each file you iterate through. Add those to list with the data you need. ( hint, create a list of objects in which your object reflects the data you need such as path, type etc,... ). If its an avi don't toss it in the list but flash a warning (messagebox?) instead.
From here the original question gets fuzzy. What exactly do you need in the pdf. Just the filenames and locations or do you actually want to throw the actual contents of the file in pdf?