Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-05-2014, 12:05 PM
|
#1
|
LQ Newbie
Registered: Feb 2006
Posts: 27
Rep:
|
Why I can't leave Windows XP for Linux (gui file search required)
Currently I have 9 actve PCs in my home network. With one exception, all of them are dual boot - Windows and Linux, but each spends most of its time running one OS. So there are 3 running Windows XP Pro SP2, 2 running Windows 7 starter, 1 ubuntu 11.04, 1 Mint 11, and 2 running Lubuntu 13.10. There are also 2 NAS units, an Android tablet, an Android smartphone and a smart TV. As well as internal drives there are many external hard drives. Total storage around 24TB.
The general purpose PC at the centre of the system is a laptop runnng XP. The termination of Windows XP updates isn't of immediate concern since I haven't accepted any XP updates for several years but I am beginning to notice other more subtle consequences of XP's old age. So I took a look at the software I was using on the laptop and almost all of it is either cross-platform or will run with Wine. The big problem is file management. In my experience so far, the XP version of Windows Explorer beats all other file managers I have tried, both Windows and Linux. It has its faults but all the others are worse.
This is what I want to do
1. Search selected network drives / partitions / directories for files by name using wildcards
2. Place the results in a window so that one or more can be selected for cut, copy, edit, rename and delete
3. When files are copied or moved, it is essential that the "date modified" property is preserved.
NB. Partition formatting may be ext2, ext3, ext4, fat32 or ntfs for source and / or destination.
I can do all of the above using XP Windows Explorer. It allows me to specify a search path of the form
D:\WORK;H:\;I:\;L:\CAPTURE;M:\;N:\;O:\;P:\;Q:\;R:\;T:\;U:\;\\Nas1\vf\WORK;X:\;Y:\;
Some of the drive letters refer to local partitions and some remote. Drive letters are not always necessary but they help to keep the string short.
(For anybody who may be interested - I have found that the first location in the path must be local but it can also be empty.)
Typically the filename part of the search looks like "*MARY*WEDDING*.AVI";"*JOHN*PARTY*.AVI";
On one linux PC I have most of the network partitions mounted under /media. As an experiment I set up a Windows XP virtual machine in VirtualBox and used it to search all or part of /media. It worked rather well.
So here's a challenge to any linux expert who happens to read this. Can you tell me how to do an equivalent search using linux?
I have posted this question on at least one other forum website.
|
|
|
06-05-2014, 12:23 PM
|
#2
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
i just tested this out in nautilus-2.32.2.1 and it doesnt allow for regex's in search (i assume gnome-3 nautilus is similar).
for anything like this i would feel more comfortable dropping to a shell and running find.
|
|
|
06-05-2014, 01:19 PM
|
#3
|
LQ Newbie
Registered: Feb 2006
Posts: 27
Original Poster
Rep:
|
I believe that multiple command line searches would be necessary in order to find all of the desired files, especially if the searches are applied only to selected parts of the mounted filesystems. The next requirement is to combine all of the results in a single list and then to present this list in some sort of tabular format in order to facilitate single and multiple selection for editing, copying etc. Most file searching software seems to be targetted at finding one specific file wherever it may be, even on the internet. I am somewhat shocked that it appears that my requirement is so rare that no linux programmer has seen the opportunity to create suitable software. I am tempted to write it myself but it would take me weeks of time I don't have, to learn the necessary programming skills.
Last edited by e_james; 06-05-2014 at 03:20 PM.
|
|
|
06-05-2014, 03:55 PM
|
#4
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
Code:
find /media /mnt -name "*MARY*WEDDING*.AVI" -o -name "*JOHN*PARTY*.AVI"
maybe you can put it in something like a zenity script but i dont think you would be able to drag-and-drop the results to a new directory.
this is more complicated but i like it better since it uses the file command (notice that it picked up transformers even though some idiot mis-labeled it as an mp3):
Code:
[schneidz@mom moo-vees]$ find . -exec sh -c "file '{}' | grep AVI, &>/dev/null" \; -printf "%p\n"
./blue-hill-ave.avi
./paprika-640x480.avi
./transformers.mp3
./pelican-brief.avi
...
Last edited by schneidz; 06-05-2014 at 04:20 PM.
|
|
|
06-06-2014, 09:05 AM
|
#5
|
LQ 5k Club
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,450
|
Wouldn't it be cool if you did not have to wait for Windows Explorer to search all those partitions, but rather just consult a prebuilt index?
Quote:
On one linux PC I have most of the network partitions mounted under /media.
|
So you could set up slocate on that Linux PC to index those partitions.
Then, in a terminal emulator
Code:
locate -r ".*MARY.*WEDDING.*AVI\|.*JOHN.*PARTY.*AVI"
would produce a list of files.
Then you can further process that list as you want. Copy and paste with a mouse. Pipe to another command to copy, rename, delete etc.
It is not the GUI solution you are seeking, but is in practice quicker and more flexible.
|
|
|
06-06-2014, 10:19 AM
|
#6
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
does gnome-3 allow nautilus-scripts ? i have a few ideas for a couple of hax that provide some functionality but probably nothing as efficient as the win-xp search:
Code:
for fn in `find /media -exec sh -c "file '{}' | grep AVI, &>/dev/null" \; -printf "%p\n"`
do
zenity --file-selection --filename="$fn" --multiple --title="Select a File"
done
this would be annoying for a large number of files since it is creating a zenity file navigator gui for each file that is found (but still allows you to drag-and-drop).
something like this is more efficient:
Code:
mkdir tmp-fn
for fn in `find /media -exec sh -c "file '{}' | grep AVI, &>/dev/null" \; -printf "%p\n"`
do
ln -s $fn tmp-fn
done
zenity --file-selection --filename=tmp-fn --multiple --title="Select a File"
but it only displays sym-links to all the files found.
Last edited by schneidz; 06-06-2014 at 10:39 AM.
|
|
|
06-09-2014, 10:14 AM
|
#7
|
LQ Newbie
Registered: Feb 2006
Posts: 27
Original Poster
Rep:
|
Thank you all for your suggestions. In case you were wondering, I haven't gone away. I have been thinking through the problems and, as I mentioned earlier, I see the whole issue as three distinct parts.
1. File search
I did a few experiments and I think this can be accomplished by a combination of Python and Bash using find (or maybe slocate). It would be good if I can figure out why find -exec doesn't work for me.
http://www.codecoffee.com/tipsforlinux/articles/21.html
3. File operations
Again I believe that Python + Bash can handle the details.
2. Multiple file selection
This is the tricky one. I don't think I have ever written a programme that does multiple selections of anything in the way that a windows file manager does. On the other hand there's NSWEEP / NSWP which, if I remember correctly, used something like check boxes. That I can probably do.
Presumably Python has libraries for all sorts of window management and probably at least one file manager, but I have barely got past "hello world" at this time.
In the last few minutes I realised that I already have a programme which does file search and multiple selection in Windows XP. I use it many times every day. It's written in Object Pal for Paradox 7. Paradox 7 will run in Linux with Wine. Allocating a drive letter to /media as mentioned above should let Paradox do everything I need - in theory. I will need to do some tests to confirm my suspicions and, if it works out, it will take me at least a few days to write the necessary code.
Further comments and suggestions are invited, especially about things to avoid.
|
|
|
06-09-2014, 10:41 AM
|
#8
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
Quote:
Originally Posted by e_james
... It would be good if I can figure out why find -exec doesn't work for me...
|
find has some hard-to-remember syntax but someone mite be able to correct your command if you post the command and the error you are getting.
|
|
|
06-09-2014, 11:25 AM
|
#9
|
LQ Newbie
Registered: Feb 2006
Posts: 27
Original Poster
Rep:
|
I took this example from the above link
Code:
$ find / - name 'Metallica*' -exec ls -l {\}\ \;
and modified it to this
Code:
$ find -iname '*.py' -exec ls -l {\}\ \;
and this is the result
Code:
$ find -iname '*.py'
./.config/calibre/global.py
./.config/calibre/gui.py
./.config/calibre/conversion/pdf_input.py
./.config/calibre/conversion/search_and_replace.py
./.config/calibre/conversion/heuristics.py
./.config/calibre/conversion/debug.py
./.config/calibre/conversion/look_and_feel.py
./.config/calibre/conversion/toc.py
./.config/calibre/conversion/epub_output.py
./.config/calibre/conversion/page_setup.py
./.config/calibre/conversion/structure_detection.py
./.config/calibre/conversion/mobi_output.py
./.config/calibre/conversion/metadata.py
./.config/calibre/tweaks.py
./.wine-browser/drive_c/windows/system32/gecko/2.21/wine_gecko/js-gdb.py
./progs/ptest2.py
./progs/ptest.py
./progs/ptest3.py
./.xbmc/addons/weather.wunderground/default.py
./.xbmc/addons/weather.wunderground/resources/lib/utilities.py
./.xbmc/addons/weather.wunderground/resources/lib/wunderground.py
$ find -iname '*.py' -exec ls -l {\}\ \;
find: missing argument to `-exec'
|
|
|
06-09-2014, 11:29 AM
|
#10
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
i think there are typos in your commands (copy-pasta error):
Code:
schneidz@hyper ~]$ find / - name 'Metallica*' -exec ls -l {\}\ \;
find: missing argument to `-exec'
[schneidz@hyper ~]$ find -iname '*.py' -exec ls -l {\}\ \;
find: missing argument to `-exec'
not exactly sure what you are trying to accomplish but is this a good guess:
Code:
[schneidz@hyper ~]$ find e-james/
e-james/
e-james/world.py
e-james/l33t
e-james/shadow-law
e-james/shadow-law/chun-li.py
e-james/shadow-law/akuma.py
e-james/hello.py
e-james/h4x0rz
[schneidz@hyper ~]$ find e-james/ -name "*.py" -exec ls -l '{}' \;
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 e-james/world.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 e-james/shadow-law/chun-li.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 e-james/shadow-law/akuma.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 e-james/hello.py
this seems more comprhensive:
Code:
[schneidz@hyper ~]$ find e-james/ -exec sh -c "file '{}' | grep \"Python script\" &>/dev/null" \; -printf "%M\t%u\t%g\t%s\t%t\t%p\n"
-rw-r--r-- schneidz schneidz 3377 Mon Jun 9 12:59:29.0112056985 2014 e-james/default.mp3
-rw-r--r-- schneidz schneidz 8589 Mon Jun 9 12:57:26.0309861449 2014 e-james/plugin.video.schneidz-academic-earth/default.py
-rw-r--r-- schneidz schneidz 3250 Mon Jun 9 12:49:42.0582348104 2014 e-james/schneidz-movie-showtimes/default.py~
-rw-r--r-- schneidz schneidz 3377 Mon Jun 9 12:49:42.0583348107 2014 e-james/schneidz-movie-showtimes/default.py
-rw-r--r-- schneidz schneidz 2736 Mon Jun 9 12:49:51.0127431241 2014 e-james/schneidz-onion/default.py
-rw-r--r-- schneidz schneidz 9160 Mon Jun 9 12:57:53.0779128915 2014 e-james/plugin.video.schneidz-abg/default.py
notice none of the empty *.py files above are returned since they are not really python files also it found a python script that was mislabeled as a .mp3 file.
Last edited by schneidz; 06-09-2014 at 12:11 PM.
|
|
|
06-09-2014, 12:18 PM
|
#11
|
LQ Newbie
Registered: Feb 2006
Posts: 27
Original Poster
Rep:
|
Thanks for the correction.
Maybe this will explain my ideas
Code:
#!/usr/bin/env python
# save this code as "file_search_test.py" and run
import subprocess
subprocess.call("find -iname '*.py' -exec ls -l '{}' \; > file_search_result.txt", shell=True)
Last edited by e_james; 06-09-2014 at 12:20 PM.
|
|
|
06-09-2014, 12:59 PM
|
#12
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
Quote:
Originally Posted by e_james
Thanks for the correction.
Maybe this will explain my ideas
Code:
#!/usr/bin/env python
# save this code as "file_search_test.py" and run
import subprocess
subprocess.call("find -iname '*.py' -exec ls -l '{}' \; > file_search_result.txt", shell=True)
|
nice script (i didnt know about subprocess). fyi:
Code:
[schneidz@hyper e-james]$ ./e-james.py
[schneidz@hyper e-james]$ cat file_search_result.txt
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 ./world.py
-rw-r--r--. 1 schneidz schneidz 8589 Jun 9 12:57 ./plugin.video.schneidz-academic-earth/default.py
-rw-r--r--. 1 schneidz schneidz 3377 Jun 9 12:49 ./schneidz-movie-showtimes/default.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 ./shadow-law/chun-li.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 ./shadow-law/akuma.py
-rw-r--r--. 1 schneidz schneidz 2736 Jun 9 12:49 ./schneidz-onion/default.py
-rwxr--r--. 1 schneidz schneidz 185 Jun 9 13:53 ./e-james.py
-rw-rw-r--. 1 schneidz schneidz 0 Jun 9 12:42 ./hello.py
-rw-r--r--. 1 schneidz schneidz 9160 Jun 9 12:57 ./plugin.video.schneidz-abg/default.py
Quote:
Originally Posted by e_james
...
2. Multiple file selection
This is the tricky one. I don't think I have ever written a programme that does multiple selections of anything in the way that a windows file manager does. On the other hand there's NSWEEP / NSWP which, if I remember correctly, used something like check boxes. That I can probably do...
|
heres my poor attempt at creating a media-center using zenity checkboxes:
http://www.linuxquestions.org/questi...center-719104/
Last edited by schneidz; 06-09-2014 at 01:06 PM.
|
|
|
All times are GMT -5. The time now is 10:47 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|