extended DIR syntax?

  • Thread starter CSGalloway@nc.rr.com
  • Start date
C

CSGalloway@nc.rr.com

Guest
Hi,

C:\> global /i /q for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren /n "%fn" %@le
ft[-15,%@name["%fn"]].jpg

Is there a way to make sure the MA are both uppercase - besides doing a:

IF @INSTR[start,[length],string] type test on each charachter?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
CSGalloway@nc.rr.com wrote:
| Hi,
|
| C:\> global /i /q for %fn in
| (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg)
| ren /n "%fn" %@le ft[-15,%@name["%fn"]].jpg
|
| Is there a way to make sure the MA are both uppercase - besides
| doing a:
|
| IF @INSTR[start,[length],string] type test on each charachter?

Sorry, no.
--
Steve
 
May 20, 2008
11,388
99
Syracuse, NY, USA
I had written:

---
Use DIR and a regular expression: DIR /B ::.*MA\d{8}_\d{4}\.(?i)jpg (I think).
You can use the output of the DIR command as FOR's "set".
---

But then I discovered, it seems, that DIR with regexes is not case sensitive
(even though the regex is). See my other, upcoming post.

v:\> for /f "tokens=*" %file in ( 'dir /b ::.*\.bat' ) echo %file
a b c.bat
anagram.bat
bdb.bat
ctrlc.bat
qbat.bat
test.bat

v:\> for /f "tokens=*" %file in ( 'dir /b ::.*\.BAT' ) echo %file
a b c.bat
anagram.bat
bdb.bat
ctrlc.bat
qbat.bat
test.bat

On Sun, 19 Jul 2009 17:05:53 -0500, "CSGalloway@nc.rr.com"
<> wrote:

|Hi,
|
|C:\> global /i /q for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren /n "%fn" %@le
|ft[-15,%@name["%fn"]].jpg
|
|Is there a way to make sure the MA are both uppercase - besides doing a:
|
|IF @INSTR[start,[length],string] type test on each charachter?
|
|
|
|
|
|
--
- Vince
 
May 20, 2008
603
0
Sammamish, WA
global /i /q (*dir /b
*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg |
*ffind /c /v /m /k
/T"MA" | for %fn in (@con:) echo ren /n "%fn" %@left[-15,%@name["%fn"]].jpg)

Ugly, but seems to work. Piping through ffind /c is the key for my attempt.

On Sun, Jul 19, 2009 at 3:05 PM,
CSGalloway@nc.rr.com<> wrote:

> Hi,
>
> C:\> global /i /q for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren /n "%fn" %@le
> ft[-15,%@name["%fn"]].jpg
>
> Is there a way to make sure the MA are both uppercase - besides doing a:
>
> IF @INSTR[start,[length],string] type test on each charachter?
>
>
>
>
>
>
>



--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
May 20, 2008
603
0
Sammamish, WA
Of course, remove the "echo" that I was using for testing.

On Mon, Jul 20, 2009 at 8:27 AM, Jim Cook<jimrcook@gmail.com> wrote:

> global /i /q (*dir /b
> *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg |
> *ffind /c /v /m /k
> */T"MA" | for %fn in (@con:) echo ren /n "%fn" %@left[-15,%@name["%fn"]].jpg)
>
> Ugly, but seems to work. Piping through ffind /c is the key for my attempt.
>
> On Sun, Jul 19, 2009 at 3:05 PM,
> CSGalloway@nc.rr.com<> wrote:
>> Hi,
>>
>> C:\> global /i /q for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren /n "%fn" %@le
>> ft[-15,%@name["%fn"]].jpg
>>
>> Is there a way to make sure the MA are both uppercase - besides doing a:
>>
>> IF @INSTR[start,[length],string] type test on each charachter?
>>
>>
>>
>>
>>
>>
>>
>
>
>
> --
> Jim Cook
> 2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Sunday.
>



--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Jim Cook wrote:
| global /i /q (*dir /b
| *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
| |
| *ffind /c /v /m /k
| /T"MA" | for %fn in (@con:) echo ren /n "%fn"
| %@left[-15,%@name["%fn"]].jpg)
|
| Ugly, but seems to work. Piping through ffind /c is the key for my
| attempt.

The only problem is that a filename like zMAzma00000000_0000.jpg matches all
the tests, even though not matching the intended test.

I don't see an alternative to using an IF test using the EQC operator on the
specific characters, something like this:

do fn in /s
*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
set n=%@name["%fn"]
if "%@left[2,%@right[15,%n]]" EQC "MA" ren "%fn" %@left[-15,%n]].jpg
enddo

BTW, Charles, are you sure you wanted %@left[-15,%@name["%fn"]], which keeps
the leftmost 15 characters, potentially dropping some of the digits, rather
than %@right[15,%@name["%fn"]] which would strip all characters matching the
* portion of the search string, retaining MA and all digits?
--
Steve
 
May 20, 2008
603
0
Sammamish, WA
I guess it's easier to use ffind to do the whole match, since the
regular expression (/e"...") is case sensitive.

Does this do it?

global /i /q (dir/b | ffind /k /m /v /e"MA\d{8,8}_\d{4,4}\.jpg$" | for
%fn in (@con:) ren /n "%fn" %@left[-15,%@name["%fn"]].jpg)

On Mon, Jul 20, 2009 at 9:29 AM, Steve Fábián<> wrote:

> Jim Cook wrote:
> | global /i /q (*dir /b
> | *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
> | |
> | *ffind /c /v /m /k
> | /T"MA" | for %fn in (@con:) echo ren /n "%fn"
> | %@left[-15,%@name["%fn"]].jpg)
> |
> | Ugly, but seems to work. Piping through ffind /c is the key for my
> | attempt.
>
> The only problem is that a filename like zMAzma00000000_0000.jpg matches all
> the tests, even though not matching the intended test.
>
> I don't see an alternative to using an IF test using the EQC operator on the
> specific characters, something like this:
>
> do fn in /s
> *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
> *set n=%@name["%fn"]
> *if "%@left[2,%@right[15,%n]]" EQC "MA" ren "%fn" %@left[-15,%n]].jpg
> enddo
>
> BTW, Charles, are you sure you wanted %@left[-15,%@name["%fn"]], which keeps
> the leftmost 15 characters, potentially dropping some of the digits, rather
> than %@right[15,%@name["%fn"]] which would strip all characters matching the
> * portion of the search string, retaining MA and all digits?
> --
> Steve
>
>
>
>
>



--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
C

CSGalloway@nc.rr.com

Guest
----- Original Message -----
From: "Jim Cook" <>
To: <CSGalloway@nc.rr.com>
Sent: Monday, July 20, 2009 06:08 PM
Subject: RE: [Support-t-1245] extended DIR syntax?



>I guess it's easier to use ffind to do the whole match, since the
> regular expression (/e"...") is case sensitive.
>
> Does this do it?
>
> global /i /q (dir/b | ffind /k /m /v /e"MA\d{8,8}_\d{4,4}\.jpg$" | for
> %fn in (@con:) ren /n "%fn" %@left[-15,%@name["%fn"]].jpg)
>
> On Mon, Jul 20, 2009 at 9:29 AM, Steve Fábián<> wrote:
>
>
> ---Quote---
>> Jim Cook wrote:
>> | global /i /q (*dir /b
>> | *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
>> | |
>> | *ffind /c /v /m /k
>> | /T"MA" | for %fn in (@con:) echo ren /n "%fn"
>> | %@left[-15,%@name["%fn"]].jpg)
>> |
>> | Ugly, but seems to work. Piping through ffind /c is the key for my
>> | attempt.
>>
>> The only problem is that a filename like zMAzma00000000_0000.jpg matches
>> all
>> the tests, even though not matching the intended test.
>>
>> I don't see an alternative to using an IF test using the EQC operator on
>> the
>> specific characters, something like this:
>>
>> do fn in /s
>> *MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg
>> *set n=%@name["%fn"]
>> *if "%@left[2,%@right[15,%n]]" EQC "MA" ren "%fn" %@left[-15,%n]].jpg
>> enddo
>>
>> BTW, Charles, are you sure you wanted %@left[-15,%@name["%fn"]], which
>> keeps
>> the leftmost 15 characters, potentially dropping some of the digits,
>> rather
>> than %@right[15,%@name["%fn"]] which would strip all characters matching
>> the
>> * portion of the search string, retaining MA and all digits?

Steve, if you notice the %@left[-15,%@name["%fn"]] will actually take all
but the 15 rightmost charachters, due to the minus 15 and not the positive
15. And I had forgotten about the EQC test - thanks. Now it will be easier
to test the two charachters together.


>> --
>> Steve
>>
>>
>>
>>
>>
> ---End Quote---
>
>
> --
> Jim Cook
> 2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Sunday.
>
>
>
>
>
 
Similar threads
Thread starter Title Forum Replies Date
fishman@panix.com HELP!! I just updated to Version 28 and as usual I cannot make extended directory search work. Support 2
vefatica Disable extended directory searches (completely)? Support 8
vefatica Extended directory searches? Support 6
G Extended directory search not working Support 4
C See if a file name matches extended range. Support 15
gschizas Fixed Cannot use extended path to delete invalid file Support 3
fishman@panix.com Extended Directory Searches are not working for me in CDD Support 9
M Problem with Extended Search and non-ASCII characters in directories names Support 3
J Extended directory search has stopped working Support 9
J Extended directory search - cure by renaming tcmd.ini Support 10
S Problem with extended wildcards Support 1
J Initialise; Alias; Extended directory search Support 2
Y TCDIALOG extended Support 1
J Extended directory search - spaces in names Support 5
J Extended support Support 0
rconn Extended Support keys sent Support 0
E Fixed Bug with DIR /Z displaying descriptions Support 8
J Paths shown in DIR /B Support 2
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
Jesse Heines How to? How to display picture creation date with dir command Support 6
vefatica WAD DIR.BTM? Support 11
DrusTheAxe DIR reports meaningless SYMLINK information Support 14
C show file description? with dir? Support 8
vefatica DIR /F and streams? Support 7
rps Multi-column DIR /v not displaying all files. Support 5
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
rps Dir /Nfv -> Alt-F2 Support 2
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
A TCMD - Dir Command puts out blank lines? Support 16
S Problems with dir command in the debugger Support 5
M TCC incorrect dir output since Windows 1803 Support 6
x13 Problem listing repository files using DIR http(s)://... Support 8
cxxl dir /s works in mysterious ways :( Support 4
vefatica Help nit (FFIND and DIR with /S) Support 0
N Fixed Strange dir behavior Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
C 7zip with date range .vs. filelist created with dir and daterange Support 0
D Towards shared (dir-)history lists Support 3
vefatica WAD DIR /HL still gets names wrong Support 16
vefatica DIR /S /HL? Support 4
H Fixed DIR /G returns wrong sizes Support 2
nickles WAD dir.htm Support 2
vefatica DO dir in /s /a:+d /d"g:\" * ( ... ) Support 26
vefatica DIR \\.\...? Support 4
M Fixed DIR /S /B1 ignores "/S" Support 5
C tcmd.ini not loading from program dir? Support 5
D Fixed Dir /Nm:n has changed Support 1
rps How to? dir /s unexpected results Support 10
vefatica Update to current install dir? Support 8
cgunhouse Problem with "dir /=" Support 4

Similar threads