how search all *.mp3 and *.wav files in my computer? Visual Studio 2015, Universal Windows App, C++/CX. Thanks
The only way to read the user's files (pictures, music, etc.) is to use the StorageFolder APIs. If you assume the music is all inside the Music library, you can simply declare the musicLibrary capability and then use KnownFolders.MusicLibrary as the root folder to search. If you really want to search the entire drive, you need to use FolderPicker and ask the user to select the root directory.
If you want to search in cmd (console):
C:\> where *.mp3
Or maybe search in disk D: not using cd command:
C:\> where /R D:\ *.mp3
In C++ code(to show the user):
#include<windows.h>
#include<string>
using namespace std;
//Be carefull: dont use: "C:\Folder\", but: "C:\\Folder\\"; In some cases you can write: "C:/Folder/"
string command = "where /R Disk:\\StartSearchFolder\\ filename"; //filename can be "ex.txt", "*.txt", "ex*";
system(command.c_str());
Can be helpful use ShellExecute()
Related
I want to use exiftool to change the names of my files in one directory to the creation time (I'm on Windows 10).
I "installed" exiftool under C:\Windows as recommended.
I also set the path for exiftool.
I created a directory under the path C:\testordner where I copied all
my files into.
I opened the commandline in windows.
When I enter the command: C:\testordner>exiftool . everything works and i get the exif data of all files inside this directory.
When I enter the command: C:\testordner>exiftool IMG_0160.JPG it works too.
After reading the documentation I tried the following command to change the filenames of all my files in the directory to the creationdate:
C:\testordner>exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" .
When I try to run this command I always get the error message: "System cannot find the specified file" (In german: Das System kann die angegebene Datei nicht finden.)
I also tried:
C:\testordner>exiftool '-FileName<CreateDate' -d %Y-%m-%d_%H.%M.%S%%.%%le .
What do I do wrong? I don't get it.
From the exiftool main page, Running in Windows:
"Note that when typing commands in the "cmd.exe" shell, you should use double quotes instead of single quotes as shown in some examples"
Under Windows CMD, change the single quotes to double quotes and your command works correctly.
My security cameras recorder (located in distant place), FTP`s to my server video files after any event. It automatically creates sudirs with name containing date of day. Using find and ffmpeg commands, server converts DAV file to AVI and remove DAV file. After that, each video file has name like this:
19.38.41-19.38.55[M][#0][0].dav.avi
I want to change above name to format like this:
19-38-41.avi
How can I do it in the same "find" command line
find -name '*.dav.avi' -execdir rename ... {} \;
See "Rename multiple files in Unix" for the rename syntax.
I want to change file names in a folder in a way like this:
previous form new form
one-1 to VAS-M0001-001
one-2 to VAS-M0001-002
one-3 to VAS-M0001-003
one-4 to VAS-M0001-004
Can anyone please suggest me a good way to do that?
I would just use a simple loop:
for f in one-*; do mv one-$f VAS-M001-000$f; done
Of course, you can use printf to format the number better (if you have more than 9 files)
rename has such a functionality
[username#hostname aa]$ touch one-1 one-2 one-3 one-4
[username#hostname aa]$ ls
one-1 one-2 one-3 one-4
[username#hostname aa]$ rename one- VAS-M0001-000 one*
[username#hostname aa]$ ls
VAS-M0001-0001 VAS-M0001-0002 VAS-M0001-0003 VAS-M0001-0004
I have been trying to do a search of the user directory and subdirectories in a primary school for all applications, music, videos and archived files to check what the kids are hiding from me. I have been using a basic dir script similar to this:
dir C:\Sample\*.exe, C:\Sample\*.rar, C:\Sample\*.mp3 /s /b /OE > D:\Result.txt
This provides me with an output of ALL files of those types sorted by user name.
What I want to know is, is there an easy way to either change the search to sort by type or to use the sort command afterwards to sort by the last character/s of the file.
Sample of output:
U:\adwan4\My Documents\My Videos\PhotoStory1.wmv
U:\ageeg2\My Documents\install_flashplayer11x32ax_gtbp_chra_aih.exe
U:\amcka55\My Documents\My Music\Angus.wmv
I have come up with something that appears to do the trick using Find along the lines of:
Find ".exe" D:\Result.txt >>D:\Sorted.txt
This appears to work fine for the avi, exe, etc. However I would be very happy for any suggestions.
Here you go
for %%x in (exe,mp3) do (
for /r C:\Dir %%a in (*.%%x) do echo %%a >>D:\Results.txt
)
For anyone interested, my initial solution (which took a lot more typing because it has no loops) looks something like this:
ECHO Off
dir U:\*.exe, U:\*.rar, U:\*.mp3 /s /b > D:\Result.txt
Echo Applications > D:\Sorted.txt
Echo --------------------------- >>D:\Sorted.txt
Find ".exe" D:\Result.txt >>D:\Sorted.txt
Echo Music >> D:\Sorted.txt
Echo --------------------------- >>D:\Sorted.txt
Find ".mp3" D:\Result.txt >>D:\Sorted.txt
Echo --------------------------- >>D:\Sorted.txt
Find ".wma" D:\Result.txt >>D:\Sorted.txt
etc
A lot more work to setup and is a 2 step process. The solution doesn't look as elegant as either option presented to me either. Thanks for your help.
The DIR /O sort option works fine when run without the /S option. But when you use the /S option it sorts the results within each directory individually, whereas you want to sort the entire result set.
Bali C's edited answer solves the problem by performing multiple searches individually, one per file extension. He chose to use the FOR command to iterate the files and ECHO the results. I believe it is simpler just to use multiple DIR commands.
>d:result.txt (
dir /s /b C:\Sample\*.exe
dir /s /b C:\Sample\*.rar
dir /s /b C:\Sample\*.mp3
)
or, perhaps a bit less typing
>d:result.txt (
for %%X in (exe rar mp3) do dir /s /b C:\Sample\*.%%X
)
I'm using ImageMagick to do some image processing from the commandline, and would like to operate on a list of files as specified in foo.txt. From the instructions here: http://www.imagemagick.org/script/command-line-processing.php I see that I can use Filename References from a file prefixed with #. When I run something like:
montage #foo.txt output.jpg
everything works as expected, as long as foo.txt is in the current directory. However, when I try to access bar.txt in a different directory by running:
montage /some_directory/#bar.txt
output2.jpg
I get:
montage: unable to open image
/some_directory/#bar.txt: No such file
or directory # blob.c/OpenBlob/2480.
I believe the issue is my syntax, but I'm not sure what to change it to. Any help would be appreciated.
Quite an old entry but it seems relatively obvious that you need to put the # before the full path:
montage #/some_directory/bar.txt output2.jpg
As of ImageMagick 6.5.4-7 2014-02-10, paths are not supported with # syntax. The # file must be in the current directory and identified by name only.
I haven't tried directing IM to pull the list of files from a file, but I do specify multiple files on the command line like this:
gm -sOutputFile=dest.ext -f file1.ppm file2.ppm file3.ppm
Can you pull the contents of that file into a variable, and then let the shell expand that variable?