topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 2:06 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: A software for compress file and able to find them first  (Read 8517 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
A software for compress file and able to find them first

I try to explain. Excuse my language.
I would to scan my hard disk (or disks) for a file with certain conditions.

By example : locate the file       "abc.txt"

When find the file compress to a rar file.

That all.

But compress seperate each file found in his own folder.


By example :

y:\path1\abc.txt to y:\path1\abc.rar

y:\path1\path2\abc.txt to y:\path1\path2\abc.rar

That all I need

Best Regards


More complete more powerful.

 :-*

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #1 on: July 31, 2012, 05:36 PM »
Take a look at a port of Linux find command.  Once you learn the syntax it's simple to have each result launch a command with the result itself as an argument.

http://gnuwin32.sour...ge.net/packages.html


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #2 on: July 31, 2012, 06:34 PM »
going

Best Regards
 :P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #3 on: August 01, 2012, 06:16 AM »
 :-[

Miles is a little difficult for me. It's a wonderful soft package for the dos console.
Is there a soft more GUI or interactive for dummies ?

Best Regards
 :P

eleman

  • Spam Killer
  • Supporting Member
  • Joined in 2009
  • **
  • default avatar
  • Posts: 413
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #4 on: August 01, 2012, 06:18 AM »
Copy the command line utility of winrar (rar.exe) into somewhere in the path (i.e. windows folder)

Put this in a batch file (*.cmd or *.bat) and run this in the relevant folder.
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"

I know this does not scan the whole disk for subfolders, but only the current folder, but you can develop the batch file a bit.

MilesAhead's proposed solution may be easier though.

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #5 on: August 01, 2012, 06:27 AM »
Just now I did this (I have Locate32 and HAOzip installed, I think any archiver would probably do)

  • Brought up Locate32 (I can bring it up using Win-F on my system)
  • Did a search for .py (Python) files
  • Selected a dozen files from the search results.
  • Right clicked on the selected results
  • Clicked HaoZip > Add to archive (Note: the Windows Explorer right click menu is replicated in Locate32)
  • Clicked Browse and browsed to the Desktop
  • Gave the filename Test.zip and hit OK.
  • Opened the file Test.zip from the desktop and there were all the files I selected.

Is that something like what you need? (Re-reading the original post, I guess you are needing something more automated. It is a little more GUI, though. ;) )
« Last Edit: August 01, 2012, 06:34 AM by daddydave »

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #6 on: August 01, 2012, 06:46 AM »
Copy the command line utility of winrar (rar.exe) into somewhere in the path (i.e. windows folder)

Put this in a batch file (*.cmd or *.bat) and run this in the relevant folder.
for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"

I know this does not scan the whole disk for subfolders, but only the current folder, but you can develop the batch file a bit.

MilesAhead's proposed solution may be easier though.

I have a batch file that can run another batch file in the current directory and all subdirectories. Nothing special but I wanted to recreate something I had from the DOS days because I had a need at the time. I call it sweep.cmd

Code: Text [Select]
  1. @echo off
  2. setlocal
  3. set oldcd=%cd%
  4. for /R %%D in (.) do (
  5.  cd "%%D"
  6.  %*
  7. )
  8. cd /d %oldcd%
  9. endlocal


Maybe it would be of some use.

Edit: corrected a bug I just now saw, lol

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #7 on: August 01, 2012, 06:54 AM »
I would to scan my hard disk (or disks) for a file with certain conditions

What tool do you currently use to search for files on your system, are you using the Windows default or a third party tool such as Locate32 or Everything. If Windows, what version of Windows?

Are the "certain conditions" fairly constant or do you want to full search power of your chosen tool?

eleman

  • Spam Killer
  • Supporting Member
  • Joined in 2009
  • **
  • default avatar
  • Posts: 413
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #8 on: August 01, 2012, 07:07 AM »
So, combining the line I provided with the work by daddydave:
Put rar.exe into somewhere accessible such as the windows folder, and then use this as a batch file:

setlocal
set oldcd=%cd%
for /R %%D in (.) do (
 cd "%%D"
 for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"
)
cd /d %oldcd%
endlocal

Run it in the top folder where you want the compression to happen. Don't run it at your root folder or some system files which should remain txt will be compressed as well. That would be asking for trouble.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #9 on: August 01, 2012, 07:09 AM »
I would to scan my hard disk (or disks) for a file with certain conditions

What tool do you currently use to search for files on your system, are you using the Windows default or a third party tool such as Locate32 or Everything. If Windows, what version of Windows?

Are the "certain conditions" fairly constant or do you want to full search power of your chosen tool?

You read my little mind. I revived Locate32 last night.
I have certain problems with locate and use less.
My system is windows xp pro sp3

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #10 on: August 01, 2012, 07:11 AM »
So, combining the line I provided with the work by daddydave:
Put rar.exe into somewhere accessible such as the windows folder, and then use this as a batch file:

setlocal
set oldcd=%cd%
for /R %%D in (.) do (
 cd "%%D"
 for %%1 in (*.txt) do rar m -x*.rar -m5 "%%1.rar" "%%1"
)
cd /d %oldcd%
endlocal

Run it in the top folder where you want the compression to happen. Don't run it at your root folder or some system files which should remain txt will be compressed as well. That would be asking for trouble.

Going to study.

It seems that all txt file go compressed.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #11 on: August 01, 2012, 07:15 AM »
Just now I did this (I have Locate32 and HAOzip installed, I think any archiver would probably do)

  • Brought up Locate32 (I can bring it up using Win-F on my system)
  • Did a search for .py (Python) files
  • Selected a dozen files from the search results.
  • Right clicked on the selected results
  • Clicked HaoZip > Add to archive (Note: the Windows Explorer right click menu is replicated in Locate32)
  • Clicked Browse and browsed to the Desktop
  • Gave the filename Test.zip and hit OK.
  • Opened the file Test.zip from the desktop and there were all the files I selected.

Is that something like what you need? (Re-reading the original post, I guess you are needing something more automated. It is a little more GUI, though. ;) )


Not very automated.
And the zip is only one. I would like any file individually packed to the corresponding zip or rar.

 :-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #12 on: August 01, 2012, 07:17 AM »
ull search power of your chosen tool

better full search power of your chosen tool of course, but any limited solution is good too because  i need to do this task now and manually is very boring.

 :P

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #13 on: August 01, 2012, 10:07 AM »
Do you already have a text listing of the files you want compressed?  As in, something like this:

c:\path\abc.txt
c:\another\path\def.txt
c:\more\stuff\ghi.txt


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #14 on: August 01, 2012, 12:02 PM »
Do you already have a text listing of the files you want compressed?  As in, something like this:

c:\path\abc.txt
c:\another\path\def.txt
c:\more\stuff\ghi.txt



Skwire sounds me as something I must have. But...  :-[

How can I obtain the txt file listing ?


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #15 on: August 01, 2012, 03:28 PM »
I don't use WinRar so the command line may have to be fixed. I just gleaned it from eleman's post.

Script should be self-explanatory.  You should enter the path as well as filename or the script will start searching in the working directory.  For example, to search all folders on C: for readme.txt use C:\readme.txt as the command line arg.

edit: if no file specified on command line, Input Box asks for the file name. As noted above, the path in the file name with be the start of the folder search. Otherwise it will start in the folder where the script is.


Not tested as I don't have rar.exe installed

; run with filename on command line
; whatever the starting directory of the filename, it will recursively dig into all folders beneath
;

if 0 < 1
{
  InputBox,FilePat,,Enter File Name (e.g. C:\readme.txt)
  if (ErrorLevel)
    ExitApp
}
else
  FilePat = %1%

Loop, %FilePat%,,1
{
  tmp := _FilePathNoExt(A_LoopFileLongPath) . ".rar"
  RunWait,rar m -x*.rar -m5 %tmp% %A_LoopFileLongPath%
}

; --------- path manipulation functions - file doos not need to exist, but passing path="" tends to mess them up ----

_FilePathNoExt(path)
{
  return _FileDirWithSlash(path) . _FileBaseName(path)
}

_FileExt(path)
{
  SplitPath,path,,,ext
  return ext
}

_FileBaseName(path)
{
  SplitPath,path,,,,basename
  return basename
}

_FileName(path)
{
  SplitPath,path,filename
  return filename
}

_FileDir(path)
{
  SplitPath,path,,fdir
  return fdir
}

_FileDirWithSlash(path)
{
  return _FileDir(path) . "\"
}
« Last Edit: August 01, 2012, 09:46 PM by MilesAhead »

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #16 on: August 01, 2012, 07:59 PM »
 :-[

I'll try. It seems very similar to the other one give me the error windows.

Going to study

 :P

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: A software for compress file and able to find them first
« Reply #17 on: August 01, 2012, 08:02 PM »
:-[

I'll try. It seems very similar to the other one give me the error windows.

Going to study

 :P

I know the recursion works properly since I took it from a program I wrote to copy all files matching pattern in a folder tree to a single destination folder.  If you get an error it's probably the WinRar command line. You may have to fix the switches.

edit: code in previous post added InputBox if no command line filename given. So just double click if you prefer.

« Last Edit: August 01, 2012, 08:57 PM by MilesAhead »