windows和linux路径斜杆转换脚本,打开即用

前言:

windows和linux的目录路径斜杆是相反的,在ssh或者其他什么工具在win和ubuntu传文件时候经常需要用到两边的路径,有这个工具就不用手动去修改斜杆反斜杠了。之前有个在线网站,后来挂了,就想着自己搞一个脚本来用。先看效果,代码放后面了,或者直接下载脚本也行。

效果:

输入路径之后回车,它会自动识别是/或者\,并且转换成另外一种格式的路径。

编写方式:

新建一个.bat结尾的脚本,名字任意;

编辑,写入代码:

复制代码
@echo off
chcp 65001 > nul
setlocal enabledelayedexpansion

:input
set /p "input_path=请输入路径: "
if "%input_path%"=="" goto :eof

set "output_path="
set "temp_path=%input_path%"
:process_path
if not defined temp_path (
    echo 转换后的路径为: 
    echo.
    echo !output_path!
    echo.
    goto :input
)

set "char=!temp_path:~0,1!"
if "%char%"=="\" (
    set "output_path=!output_path!/!"
) else if "%char%"=="/" (
    set "output_path=!output_path!\!"
) else (
    set "output_path=!output_path!!char!"
)

set "temp_path=!temp_path:~1!"
goto :process_path

脚本下载:

资源那

相关推荐
susplus22 分钟前
【linux应用软件编程】数据库sqlite3
linux·数据库·sqlite
GeW26 分钟前
RHCE的评分潜规则:这样做实验,每题多拿20%分数
linux
运维全栈笔记26 分钟前
Windows 安装 WSL2 并运行 Ubuntu 24.04 指南
linux·网络·windows·ubuntu
FlightYe1 小时前
音视频修炼之基础理论(五):AAC格式与解析
android·linux·c++·音视频·aac
米糕闯编程1 小时前
鱼香ros2(一)在ubuntu中安装ros2
linux·运维·ubuntu·机器学习
Huangjin007_1 小时前
【Linux 系统篇(十八)】进程(六) :环境变量
linux·运维·服务器
ShineWinsu2 小时前
对于MySQL:数据库的操作的解析
linux·数据库·c++·mysql·面试·笔试·库的操作
cnnews2 小时前
Ubuntu 编译 postmarketOS
linux·运维·arm开发·ubuntu·github·音视频
w01_02_032 小时前
linux, 桌面, 自启动。
linux·运维·服务器
从零开始的嵌入式之旅2 小时前
day36
linux·c语言·经验分享·笔记·嵌入式硬件