Author Topic: Create sample subdirectories  (Read 2564 times)

Offline mysteryman

  • Contributor
  • ***
  • Posts: 66
Create sample subdirectories
« on: August 06, 2008, 04:06:10 am »
I keep a lot of what I download, and I like knowing that they are as original as possible. I am also one of those people who downloads samples whenever available. For people like me, who download samples, and like things perfect...it would be handy if samples could be redirected to a NZBNAME\Sample directory that would be auto-created as needed. This would look a lot nicer and much more like the original source.
« Last Edit: August 06, 2008, 08:43:21 am by Hecks »

Offline cr4zyfr4g

  • Global Moderator
  • *****
  • Posts: 781
  • German n00b
Re: Create sample subdirectories
« Reply #1 on: August 06, 2008, 11:16:56 am »
can be done with a default execute command:

create a "mycommands.bat" file with following lines (not tested) an place into you alt.binz folder :

Quote
set DOWNLOADDIR=%1
set UNRARDIR=%2

if exist "%UNRARDIR%\*sample*" (
mkdir %UNRARDIR%\sample
move %UNRARDIR%\*sample* %UNRARDIR%\sample )

then add this line as your default execute command:

c:\Path_to_altbinz\mycommands.bat $d $u


This is just an example you can add lots of more stuff to that .bat file


Offline mysteryman

  • Contributor
  • ***
  • Posts: 66
Re: Create sample subdirectories
« Reply #2 on: August 07, 2008, 09:14:40 am »
Thanks, that worked pretty good, I made a few adjustments though to avoid potential misdetection. I was a bit rusty on my bath scripting, felt good to brush back up on it. I'm used to more modern (powerful?) scripting on unix such as bash and tcl.

On a related note... Would you recommend any documents or books (or additional programs to use inside if) for advanced globbing and regexp on files and directories. As far as I can tell if EXIST only accepts * wildcards. If not I'll start reading up on vb or js (in non web environment). They are probably better suited to do the advanced organization I plan on.

Offline Hecks

  • Contributor
  • ***
  • Posts: 2011
  • naughty cop
Re: Create sample subdirectories
« Reply #3 on: August 07, 2008, 11:01:20 am »
If you want a bit more power than .bat, I'd avoid vbscript and go straight to Powershell, the MS replacement for commandline & vbscript:

Download here

Built by ex-Unix guys, one of the few recent developments by Microsoft that's genuinely good.  It can use any .NET class, too, so you get full regexing.  Unlike bash, it pipes objects rather than text, so it's very flexible.  I've converted all my batch scripts to PS now.

Then, of course, it's a doddle to write console apps in C#. :)

Example of Powershell regexing of files in directory, will return the file objects, which can then be copied/moved or queried:

Code: [Select]
$files = get-childitem "C:\blah"
foreach ($file in $files) {
   if ($file -match "your_regex") {
      write $file.name # echo name to console
      # do other stuff with file
   }
}


And in the abbreviated version that does exactly the same as the above using pipes:

Code: [Select]

gci "C:\blah" | ?{$_ -match "your_regex"} | %{$_.name}

« Last Edit: August 07, 2008, 11:42:48 am by Hecks »

Offline mysteryman

  • Contributor
  • ***
  • Posts: 66
Re: Create sample subdirectories
« Reply #4 on: September 03, 2008, 09:46:05 am »
maybe a revision of the previous request would be considered.... I just noticed as downloading something that some collections have very specific ways of indicating subdirectories... example...

[nnnnn]-[#chan@somewhere]-[Full]-[some-thing Sample]-[00] - some-thing.sample.avi yEnc
[nnnnn]-[#chan@somewhere]-[Full]-[some-thing Subs]-[00] - some-thing.subs.rar yEnc
OR
[nnnnn]-[#chan@somewhere]-[Full]-[some-thing~Sample]-[00] - some-thing.sample.avi yEnc
[nnnnn]-[#chan@somewhere]-[Full]-[some-thing~Subs]-[00] - some-thing.subs.rar yEnc

using this methodology (when detected) would be quite useful as sometimes the subtitles are supposed to be in a directory named differently (vobsub, subfix, etc).
« Last Edit: September 08, 2008, 06:34:34 pm by mysteryman »