當前位置:首頁 » 文件管理 » c修改文件夾名稱

c修改文件夾名稱

發布時間: 2023-07-13 20:56:39

❶ 求教!如何把win7系統的c盤的"用戶"文件夾改名為英文的「users」文件夾

win7系統的c盤的"用戶"文件夾其真實名稱即為users,無須修改。中文名用戶只是顯示名稱而已。
具體查看方法如下:
1、打開計算機,打開C盤;
2、右擊顯示為用戶的文件夾,點擊屬性;
3、點擊安全選項卡,可以看到對象名稱為C:\Users;
4、如果打開這個文件夾,再點擊地址欄,也可以看到其名稱為users。

❷ 用C語言批量更改文件名

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <iconv.h>
#include <errno.h>
/*int to_iconv(char *in,size_t in_bytes,char *out,size_t out_bytes,
const char *from,const char *to)*/
int to_iconv(char *in,char *out,size_t out_bytes,const char *from,const char *to)
{
iconv_t cd;
size_t in_bytes=strlen(in);
//size_t out_bytes;
if((cd=iconv_open(to,from)) == (iconv_t)-1)
{
perror("iconv_open");
return -1;
}
if(iconv(cd,&in,&in_bytes,&out,&out_bytes) == -1)
{
perror("iconv");
return -1;
}
iconv_close(cd);
return 0;
}
void read_and_iconv(char *path,const char *from,const char *to)
{
DIR *dirp;
struct dirent *dir;
struct stat buf;
char temp[512]; //用於保存轉換後的文件名稱
if((dirp=opendir(path)) == NULL) //讀取文件夾
{
perror("opendir");
return;
}
chdir(path); //進入到該文件夾內部
while(dir=readdir(dirp)) //讀取該文件夾下所有文件
{
if((strcmp(dir->d_name,".") == 0) || (strcmp(dir->d_name,"..") == 0))
//過濾掉.以及..文件夾,不然會死循環的
continue;
bzero(temp,sizeof(temp));
to_iconv(dir->d_name,temp,sizeof(temp),from,to); //進行編碼轉換
rename(dir->d_name,temp); //進行重命名
printf("rename %s to %s\n",dir->d_name,temp);
stat(temp,&buf);
if(S_ISDIR(buf.st_mode)) //判斷當前讀取的文件是否為文件夾
{
read_and_iconv(temp,from,to); //如果是則遞歸處理
chdir(".."); //處理完成後一定要記得返回上一層目錄哦,不然其它文件就無法處理了
}
}
closedir(dirp);
}
int main(int argc,char **argv)
{
read_and_iconv(argv[1],argv[2],argv[3]);
/*第一個參數是要轉換的文件夾所在的文件夾名稱
*第二個參數是文件名稱所使用的編碼(這里為GBK)
*第三個參數是要轉換成何種編碼(這里為UTF-8)
*/
return 0;
}

熱點內容
構成c語言程序的基本單位 發布:2025-02-04 13:49:53 瀏覽:988
如何修改已經更改的密碼 發布:2025-02-04 13:38:38 瀏覽:772
唐dm2021買哪個配置劃算 發布:2025-02-04 13:38:38 瀏覽:627
真空壓縮重 發布:2025-02-04 13:38:37 瀏覽:639
alias腳本 發布:2025-02-04 13:38:03 瀏覽:739
linux終端字元 發布:2025-02-04 12:52:40 瀏覽:735
c語言程序設計mobi 發布:2025-02-04 12:51:55 瀏覽:259
rsa演算法c語言 發布:2025-02-04 12:50:36 瀏覽:785
阿里雲伺服器託管破解 發布:2025-02-04 12:47:43 瀏覽:257
汽車都有什麼配置 發布:2025-02-04 12:42:51 瀏覽:458