0

对不起我的英语不好!我是葡萄牙语!

我想知道是否可以使用批处理制作带有“Google Chrome”的“Gif Viewer”。我想做的是“谷歌浏览器”通过“简单点击”打开gif,因为我在图形设计课程,在我们学校,电脑有管理员权限,所以我们不能更改 gifs 默认设置,由“谷歌浏览器”打开。我们想通过“Chrome”打开 gif,因为它是快速的动画 gif 显示器,并且可以预览我们在 html 中做的网站。另一个原因是因为我喜欢了解有关批处理的更多信息...

我的问题是:如何创建一个“文件搜索器”来查找 GIF1、2 或 3,并使用 google chrome 打开它(我需要这样做以避免更改 gif 和“google chrome”的目录,无论何时我更改文件夹,或将程序复制给我的同学)...

这是我的完整批次(有点动态):

ECHO OFF
CLS
TITLE ***Gif Viewer\**Hubert Kenobi**/GoogleChromePortable***
:S
color 12
color 0B
color 12
color 23
color 45
color 62
color 89
color 91
color 37
color 12
color 43
color 51
color 15
color 42
color 2
color 3
color 0A
:MENU
ECHO .
ECHO  \   
ECHO   HK 
ECHO     .......................................................
ECHO   ...                                                     ...
ECHO  ..                                                         ..
ECHO .     *--Gifs Viewer \By Hubert Kenobi/ Google Chrome--*      .    ===
ECHO  ..                                                         ..
ECHO   ...                                                     ......
ECHO     .......................................................    ...
ECHO    ..                   Y or y - Confirm                  ..     ..           
ECHO   .                   N or n - Reject/Next                  .      .  ===   ===
ECHO    ..                    E or e - Exit                    ..     ..            
ECHO     .......................................................    ...
ECHO   ...                                                     ......
ECHO  ..  To open a gif, put the gif in the folder where is the  ..
ECHO .     "Gif Viewer" with the name of Gif1, or Gif2 Gif3...     .    ===
ECHO  ..   PRESS "Y" or "N" to select your task or "E" to EXIT   ..
ECHO   ...                                                     ...
ECHO     .......................................................
ECHO   HK                                                           Hubert Kenobi
ECHO  /                                                            My spaceship!!!
ECHO .     
ECHO Do you want to see/watch gif1 ?
ECHO.

SET /P M=Type Y, N, or E, then press ENTER: 
IF %M%==Y GOTO Y
IF %M%==N GOTO N
IF %M%==E GOTO EOF
IF %M%==y GOTO Y
IF %M%==n GOTO N
IF %M%==e GOTO EOF
:Y
## I want to make a searcher that run the gif and open it with chrome!! HELP ME!!! ##
ECHO This will take few seconds...
start GoogleChromePortable.exe "L:\Informatic\GoogleChromePortable-GifViewer\Gif1.gif"
GOTO S
:N 
ECHO Do you want to see/watch gif2 ?
ECHO.

SET /P M=Type Y, N, or E, then press ENTER: 
IF %M%==Y GOTO Y2
IF %M%==N GOTO N2
IF %M%==E GOTO EOF
IF %M%==y GOTO Y2
IF %M%==n GOTO N2
IF %M%==e GOTO EOF

:Y2

## I tried this way, but it didn't work and exit automatically! ##

pushd L:\Site HTML onlive-ac
FOR /F "delims=" %F IN ('dir /S /b Gif1.gif) DO SET ExePath="%F"
%ExePath%
Goto S

:N2
ECHO Do you want to see/watch gif3 ?
ECHO.

SET /P M=Type Y, N, or E, then press ENTER: 
IF %M%==Y GOTO Y3
IF %M%==N GOTO N3
IF %M%==E GOTO EOF
IF %M%==y GOTO Y3
IF %M%==n GOTO N3
IF %M%==e GOTO EOF

:Y3
## I tried this way, but it didn't work! This opens the Gifs independently ##
## with the default program (Quick Time Player "slow program") and then ##
## opens the Chrome in the Home page. ##
SETLOCAL 

FOR /L %%a IN (2,1,3) DO (
    FOR /F "tokens=2 delims==" %%b IN ('WMIC LogicalDisk Where "DriveType=%%a" Get DeviceID /Format:List') DO (
        FOR /F "tokens=*" %%c IN ('DIR %%b\GoogleChromePortable.exe "Gif3.gif" /b /s') DO (
            CALL "%%c"
        )
    )
)

EXIT /B
N3:
GOTO MENU

这是我的摘要批次:

1.我想做一个运行gif的搜索器,用chrome打开!!!!!!这有效,但不是我想要它做的功能!帮助我!

:Y
ECHO This will take few seconds...
start GoogleChromePortable.exe "L:\Informatic\GoogleChromePortable-GifViewer\Gif1.gif"
GOTO S

2.这个方法我试过了,不行,自动退出!

:Y2
pushd L:\Site HTML onlive-ac
FOR /F "delims=" %F IN ('dir /S /b Gif1.gif) DO SET ExePath="%F"
%ExePath%
Goto S

3.这个方法我试过了,不行!这将使用默认程序(Quick Time Player“慢程序”)独立打开 Gif,然后在主页中打开 Chrome。

SETLOCAL 
    :Y3 
    FOR /L %%a IN (2,1,3) DO (
        FOR /F "tokens=2 delims==" %%b IN ('WMIC LogicalDisk Where "DriveType=%%a" Get DeviceID /Format:List') DO (
            FOR /F "tokens=*" %%c IN ('DIR %%b\GoogleChromePortable.exe "Gif3.gif" /b /s') DO (
                CALL "%%c"
            )
        )
    )

    EXIT /B

请帮我!!! 我做了一个 PrintScreen 来查看目录: http ://s5.postimage.org/h2emaxvfb/Background_Directoryies.png

一种可能的解决方案是创建第二个批处理程序来更改目录(复制或移动),从而修改第一个批处理。是否可以?修改其他批次的批次?感谢帮助!

4

1 回答 1

0

我写了一个你可以使用的文件选择器。或者您可以只查看各个部分,例如我如何启动 chrome 来显示文件。或者我如何搜索子目录中的所有图像,或者其他什么。我想展示如何在不强制用户重命名他们的 .gif 文件的情况下做到这一点。

您需要在脚本顶部配置这些变量:

REM The location of the viewer to launch.
set VIEWER=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

REM The root directory to look for files.  %~dp0 means the same directory as
REM this script, including a trailing \.
set FILES=%~dp0

REM The type of files to show.
set FILE_FILTER=^*.gif ^*.jpg ^*.png

REM When '/s', then include subdirectories below %FILES% in the search.  Leave
REM blank to restrict the search to %FILES% only.
set RECURSE=/s

当你启动选择器时,你会得到一个如下所示的菜单:

  images\buffalo.gif
  images\bull7.gif
> images\cow13.gif
  images\cow14.gif
  more images\dino 10.gif
  more images\dino19.gif
Up[W]  Down[S]  Select[E]  Quit[Q]

现在,cow13.gif被选中。按WS分别向上或向下更改选择。按E启动 chrome 以显示所选文件。 Q退出。

这是完整的事情。它使用choice,它并不总是随 Windows 一起安装。它在我的 Windows 7 盒子上,所以我使用了它。

@echo off

REM The location of the viewer to launch.
set VIEWER=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

REM The root directory to look for files.  %~dp0 means the same directory as
REM this script, including a trailing \.
set FILES=%~dp0

REM The type of files to show.
set FILE_FILTER=^*.gif ^*.jpg ^*.png

REM When '/s', then include subdirectories below %FILES% in the search.  Leave
REM blank to restrict the search to %FILES% only.
set RECURSE=/s

REM ----------------------------
setlocal EnableDelayedExpansion

cls
call :show_splash_screen
call :pause_sec 2

set SELECTED_INDEX=0
set SELECTED=

:show_files
if %SELECTED_INDEX% LSS 0 ( set SELECTED_INDEX=0)

cls
call :ui_show_files "%FILES%" "%FILE_FILTER%" "%SELECTED_INDEX%"

choice /c QWSE /n /m " Up[W]  Down[S]  Select[E]  Quit[Q]"
if ERRORLEVEL 4 (
        REM User selected an option, so launch the viewer with the selected file
 as
        REM an argument.
        call "%VIEWER%" "%SELECTED%"
        goto :show_files
)
if ERRORLEVEL 3 ( set /a SELECTED_INDEX=!SELECTED_INDEX!+1 && goto :show_files )

if ERRORLEVEL 2 ( set /a SELECTED_INDEX=!SELECTED_INDEX!-1 && goto :show_files )

goto :eof

REM ui_show_files
REM Displays all the files in the directory given by %1, filtered by %2.  %3
REM indicates which file the user has selected.
REM
REM Returns %SELECTED%, which contains the filename of the selected file.
:ui_show_files
set COUNT=0
pushd "%~1"
for /f "tokens=*" %%a in ('dir %RECURSE% /b %~2') do (
        set DISPLAY_NAME=
        if "!COUNT!"=="%~3" (
                REM This next line has a trailing space.  The space is important
.
                set DISPLAY_NAME=^>
                set SELECTED=%%a
        ) else (
                REM This next line has trailing spaces.  The spaces are importan
t.
                set DISPLAY_NAME=
        )
        set DISPLAY_NAME=!DISPLAY_NAME!%%a
        set DISPLAY_NAME=!DISPLAY_NAME:%~1=!
        echo !DISPLAY_NAME!
        set /a COUNT=!COUNT!+1
)
popd
goto :eof

REM show_splash_screen
REM Displays the splash screen on the console.
:show_splash_screen
echo.
echo. File chooser brought to you by ^>indiv^<
echo.
for %%a in (1 2 3 4 5 6 7 8 9 a b c d e f) do ( color 0%%a )
color
goto :eof

REM pause_sec
REM Pause for the number of seconds given by ~1.
:pause_sec
set SECS=%1
if "%SECS%"=="" ( set SECS=1)
ping 127.0.0.1 -n %SECS% >NUL
goto :eof
于 2012-12-07T01:15:05.377 回答