China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-23 15:09
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » A boring piece of work (VBS) that can reverse file names View 2,646 Replies 13
Original Poster Posted 2006-12-19 04:34 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
**Function: Reverse the filenames (including folders) in the current folder, keeping the extension unchanged, and the filename itself will not be reversed.
'Not guaranteed to be problem-free, use with caution! (Tested and passed on this machine)
on error resume next
set wshshell=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
set folder=fso.getfolder(WshShell.CurrentDirectory)
set files=folder.files
for each file in files
if file.name<>wscript.scriptname then
kzm=fso.GetExtensionName(file)
file.name=replace(file.name,"." & fso.GetExtensionName(file),"")
file.name=StrReverse(file.name) & "." & kzm
else
end if
next
set wjj=fso.getfolder(WshShell.CurrentDirectory)
set wjjs=wjj.subfolders
for each fd in wjjs
fd.name=StrReverse(fd.name)
next
msgbox "All filenames in the current folder have been reversed.",48+4096,"Prompt"

[ Last edited by jmz573515 on 2006-12-18 at 03:59 PM ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
redtek +5 2006-12-19 05:32
ccwan +5 2006-12-19 05:43
tireless +4 2008-02-24 18:38
Floor 2 Posted 2006-12-19 04:51 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Appreciate~~~
It's really complicated~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 3 Posted 2006-12-19 05:15 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
Then I'll write a P-processing version by the way to reverse the filenames of all files in the current directory


@echo off&setlocal
for /f "tokens=*" %%a in ('dir /b /a-d *.*') do call :pp "%%a"
pause
goto :eof
:pp
set "a=%~n1"
:loop
if not defined a goto cc
set "a=%a:~0,-1%"&set "b=%b%%a:~-1%"&goto loop
:cc
echo %b%%~x1
set b=
goto :eof


[ Last edited by 9527 on 2006-12-19 at 05:28 AM ]
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
redtek +5 2006-12-19 05:32
ccwan +5 2006-12-19 05:43
我今后在论坛的目标就是做个超级坏人!!!
Floor 4 Posted 2006-12-19 05:30 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Brother 9527, why didn't I succeed? The original code has been updated ^_^

[ Last edited by ccwan on 2006-12-19 at 05:31 AM ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 5 Posted 2006-12-19 07:32 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
The key in VBS is

file.name = StrReverse(file.name) & "." & kzm

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 6 Posted 2007-04-06 21:55 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
It's really thorough in the research. o(∩_∩)o... Haha. Learned it
Floor 7 Posted 2007-04-07 05:01 ·  中国 安徽 马鞍山 电信
中级用户
★★
Credits 397
Posts 168
Joined 2006-10-08 10:07
19-year member
UID 64934
Status Offline
It's just that the StrReverse() function is at work!
Floor 8 Posted 2008-02-23 23:16 ·  中国 辽宁 大连 联通
初级用户
Credits 83
Posts 41
Joined 2008-02-23 15:42
18-year member
UID 111267
Gender Male
Status Offline
Can you reverse the files in a specified partition? How to restore?
Floor 9 Posted 2008-02-23 23:41 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Reply again, please~
Floor 10 Posted 2008-02-24 18:13 ·  中国 辽宁 大连 开发区 联通
初级用户
Credits 83
Posts 41
Joined 2008-02-23 15:42
18-year member
UID 111267
Gender Male
Status Offline
Please let an expert write one that reverses the files in a specified partition
Floor 11 Posted 2008-02-24 18:27 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
这是一句中文的文字游戏,正常翻译就是“Pig is the thought to come倒”,不过更准确的从文字颠倒的角度直译就是“倒过来念是猪”,即“The thought of the pig comes upside down” ,但更符合原文字游戏的直白翻译就是“Pig is the念来过倒”这样不太对,重新来:原句“猪是的念来过倒”正常按文字顺序颠倒后是“倒过来念是猪”,英文直白翻译就是“Inverted, it reads pig” ,不过更准确按照原句的字符顺序翻译就是“Pig is the 念来过倒”不对,重新整理:原句“猪是的念来过倒”,把每个字倒过来读就是“倒过来念是猪”,英文翻译为“When read upside down, it is pig”
Floor 12 Posted 2008-02-24 21:52 ·  中国 香港 环球全域电讯
初级用户
★★
Credits 125
Posts 56
Joined 2008-02-20 14:01
18-year member
UID 111054
Gender Male
Status Offline
It's tough, I'm just a newbie learning. Thanks
Floor 13 Posted 2008-02-25 22:54 ·  中国 辽宁 大连 联通
初级用户
Credits 83
Posts 41
Joined 2008-02-23 15:42
18-year member
UID 111267
Gender Male
Status Offline
Can the files in a specified partition be reversed?
1、打破砂锅问到底,生下来就是这样
2、有些问题很可笑,但请不要笑,我只想从技术角度解决
Floor 14 Posted 2008-02-25 23:07 ·  中国 北京 华为云
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Originally posted by shaokui123 at 2008-2-25 10:54 PM:
Can you reverse the files in a specified partition?



Of course, make a slight modification. Or copy the file to the specified partition.

For recovery, please refer to the reply in floor 9
Forum Jump: