Windows wget UTF-8 名称
Windows wget UTF-8 names
我正在尝试创建一个连接到我的 ftp 服务器(windows 服务器 2012 R2)并下载目录树的批处理脚本。
我通过以下命令使用 GNUWin32 的 wget:
"C:\Program Files (x86)\GnuWin32\bin\wget.exe" --ftp-user=foo --ftp-password=foo ftp://ip.ip.ip.ip/directory/directory --level=0 --no-glob --continue --timestamping --tries=0 --recursive
问题是,即使在我的 ftp 服务器和数据库 (postgres) 上,所有内容都保存为 UTF-8 并正确显示。当我用 wget 下载目录树时,下载的东西没有正确的编码(例如 ü 变成 ü)
有没有办法让下载的文件夹与服务器上的文件夹同名?我已经尝试了 3 天但无济于事
P.S。我试过使用 Filezilla 强制使用 UTF-8 下载文件,它们最终得到了正确的名称,但我需要一个可以无人值守的解决方案,而 filezilla 不支持我所理解的
我设法做到了,我使用了以下 wget 命令
wget --ftp-user=%ADMIN% --ftp-password=%PASSWORD% ftp://%IP% --level=0 --no-glob --continue --tries=0 --recursive --restrict-file-names=ascii
加载强制 ASCII 编码的文件,然后此 powershell 脚本将它们转换回 UTF-8
Add-Type -AssemblyName System.Web;
# Get the filenames and order them to have the files first
$data = get-childitem %PATH_TO_FOLDER% -recurse | Sort-Object FullName -descending;
# Cycle every file
ForEach($dat in $data){
# Get the decoded UTF-8 name
$decoded = [System.Web.HttpUtility]::UrlDecode($dat.name);
# Rename the file if the decoded name is different than the current one
if ($dat.name -ne $decoded){ren $dat.FullName $decoded}
}
它可能会做得更好,但我对 powershell 的了解还不够多,无论如何这都能很好地满足我的需要
我正在尝试创建一个连接到我的 ftp 服务器(windows 服务器 2012 R2)并下载目录树的批处理脚本。
我通过以下命令使用 GNUWin32 的 wget:
"C:\Program Files (x86)\GnuWin32\bin\wget.exe" --ftp-user=foo --ftp-password=foo ftp://ip.ip.ip.ip/directory/directory --level=0 --no-glob --continue --timestamping --tries=0 --recursive
问题是,即使在我的 ftp 服务器和数据库 (postgres) 上,所有内容都保存为 UTF-8 并正确显示。当我用 wget 下载目录树时,下载的东西没有正确的编码(例如 ü 变成 ü)
有没有办法让下载的文件夹与服务器上的文件夹同名?我已经尝试了 3 天但无济于事
P.S。我试过使用 Filezilla 强制使用 UTF-8 下载文件,它们最终得到了正确的名称,但我需要一个可以无人值守的解决方案,而 filezilla 不支持我所理解的
我设法做到了,我使用了以下 wget 命令
wget --ftp-user=%ADMIN% --ftp-password=%PASSWORD% ftp://%IP% --level=0 --no-glob --continue --tries=0 --recursive --restrict-file-names=ascii
加载强制 ASCII 编码的文件,然后此 powershell 脚本将它们转换回 UTF-8
Add-Type -AssemblyName System.Web;
# Get the filenames and order them to have the files first
$data = get-childitem %PATH_TO_FOLDER% -recurse | Sort-Object FullName -descending;
# Cycle every file
ForEach($dat in $data){
# Get the decoded UTF-8 name
$decoded = [System.Web.HttpUtility]::UrlDecode($dat.name);
# Rename the file if the decoded name is different than the current one
if ($dat.name -ne $decoded){ren $dat.FullName $decoded}
}
它可能会做得更好,但我对 powershell 的了解还不够多,无论如何这都能很好地满足我的需要